Giter Site home page Giter Site logo

ansilh / docker-st2-sso Goto Github PK

View Code? Open in Web Editor NEW

This project forked from chris-crunchr/docker-st2-sso

0.0 0.0 0.0 5 KB

Basic stackstorm setup in docker with support for SSO logins with headers instead of CGI params.

Shell 1.21% Python 24.57% HTML 28.95% Dockerfile 45.28%

docker-st2-sso's Introduction

Introduction

This repository contains a docker-based stackstorm setup that enables passing authorized usernames via HTTP headers instead of WSGI parameters.

Why?

Most Single Sign On frameworks I've seen use a header (e.g. X-Forwarded-User) to pass usernames to the backend, after the authentication and authorization procedures. The backend accepts this header and does what is needed to setup a session for this user.

The authentication backend from stackstorm does not accept these headers. When ran in proxy mode, it assumes that the application framework will send the username as a WSGI parameter to the application.

In the docker setup, st2auth runs behind gunicorn. Gunicorn only accepts HTTP connection and does not support custom transformations from header to parameters. So, to accept usernames through headers, some major modifications were needed.

How?

Basically, we replace gunicorn with uwsgi and use nginx uwsgi support to transform the incoming header to a uwsgi parameter. Uwsgi is configured to run in master mode, with it's vassals living under /etc/uwsgi/vassals.

We provide two vassals: st2auth and auth_proxy. The first vassal is the gunicorn to uwsgi replacement and runs under a unix socket. The second is needed to allow the internal tooling to login. The internal stackstorm tools do not know how to cooperate with st2auth in proxy mode. For instance, st2 login <username> will always try to do a regular authentication request to localhost:9100. In proxy mode, however, st2auth will not accept these requests. To get around this issue, we created auth_proxy. This proxy accepts connection on localhost:9100 extracts the username and forwards this request to reverse proxy for dispatching.

The last problem we encountered was the default stackstorm webinterface. This interface assumes that the user provides a username and password, unless a session cookie is set (or more accurately, a session in the local browser storage). To circumvent this problem, we've added a static auth.html page. This page is loaded by nginx if no session cookie is found, instead of the default index page. This page loads the session details from the st2auth backend, prepares the local storage and cookies and, finally, reloads the page. Nginx detects that a session is active via the auth cookie and loads the normal index page, continuing the usual stackstorm flow.

Understanding the source

To form a better understanding of how this all works together I advise you to read the Dockerfile and the (last few blocks of) st2.conf nginx configuration. These files give a broad overview of how this solution works!

docker-st2-sso's People

Contributors

chris-crunchr avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.