Giter Club home page Giter Club logo

ldap-auth-gateway's Introduction

ldap-auth-gateway

Note: This is a minimum viable product... that said, it works!

about

Provides a gateway pattern for centralizing the authorization and session management of incoming HTTP requests through a reverse proxy. Authorization mechanism could be made pluggable since it is facaded by an auth service, but in the default implementation, I'm using a nodejs-based LDAP server (ldapjs).

dependencies

nodejs/npm

installation

install:

➜  ldap-auth-gateway git:(master) npm install

start ldap:

➜  ldap-auth-gateway git:(master) node ldap.js

start remaining services:

➜  ldap-auth-gateway git:(master) node app.js

working use cases

Attempt to access target via gateway, no token, no basic auth

title attempt to reach target no auth header
client->gateway:  get/post
gateway->gateway: token? (no)
gateway->auth: auth
auth->auth: parse basic auth header (no header)
auth->gateway: fail auth
gateway->client: fail auth

attempt to access target via gateway - no token, basic auth (invalid creds)

title attempt to reach target, auth header (invalid)
client->gateway:  get/post
gateway->gateway: token? (no)
gateway->auth: auth
auth->auth: parse basic auth header (okay)
auth->ldap: auth via ldap (bind)
ldap->ldap: server.bind(creds)
ldap->auth: fail
auth->gateway: fail auth
gateway->client: fail auth

attempt to access target via gateway, valid creds

title attempt to reach target, auth header (valid)
client->gateway:  get/post
gateway->gateway: token? (no)
gateway->auth: auth
auth->auth: parse basic auth header (okay)
auth->ldap: auth via ldap (bind)
ldap->ldap: server.bind(creds)
ldap->auth: succeed
auth->gateway: auth success!
gateway->client: auth success, set token (cookie)

attempt to access target via gateway, valid token

title attempt to reach target, (valid token)
client->gateway:  get/post
gateway->gateway: token? (yes!)
gateway->target: proxy request
target->target: echo response
target->gateway: proxy response
gateway->client: target's response

Example usage

Examples assume running on localhost....

Use case: Invalid basic auth, no existing session
User attempts to access target through gateway with no session and no (or invalid) auth credentials.
➜  ~  curl --header "Authorization:  Basic cm9iOnJvYg==" localhost:8000
Not authorized.
Use case: Valid basic auth, no existing session
User attempts to access target through gateway with no session and valid auth credentials (login: root, password: secret).
➜  ~  curl --header "Authorization:  Basic cm9vdDpzZWNyZXQ=" localhost:8000
Authorized.
Use case: User has a valid session after successful authorization
Here, simple token is validated and forwarded to an echo service. Not the x headers indicating the forward. Note, roadmap item will include client-based secure sessions with TTL... likely via the Express Framework.
➜  ~  curl -X POST -d "foo" --header "Cookie:  token=12345678" localhost:8000
Echo service: /
{
  "user-agent": "curl/7.24.0 (x86_64-apple-darwin12.0) libcurl/7.24.0 OpenSSL/0.9.8x zlib/1.2.5",
  "host": "localhost:8000",
  "accept": "*/*",
  "cookie": "token=12345678",
  "content-length": "9",
  "content-type": "application/x-www-form-urlencoded",
  "x-forwarded-for": "127.0.0.1",
  "x-forwarded-port": "52581",
  "x-forwarded-proto": "http",
  "connection": "keep-alive"
}foo

Roadmap

  • Make auth a service call from gateway to auth, rather than a proxy.
  • Move token check into auth proxy so that all auth session logic is handled here... making gateway rely on auth completely.
  • Fix home grown parsing of cookies/basic auth. Likely using Express framework.
  • Back LDAP with a user seed file, and offer a non-memory based alternative, ie backed by RIAK.
  • Move port and other config to a config file.
  • Metrics server falls down on heavy load

ldap-auth-gateway's People

Contributors

robertjchristian avatar

Watchers

 avatar  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.