GithubHelp home page GithubHelp logo

heipei / nginx-sso Goto Github PK

View Code? Open in Web Editor NEW
97.0 8.0 14.0 2.51 MB

Simple SSO system for nginx based on cookies and ECDSA

License: GNU General Public License v2.0

Makefile 0.86% Nginx 11.74% Go 87.40%

nginx-sso's Introduction

nginx-sso - Simple offline SSO for nginx

nginx-sso is a simple single-sign-on (SSO) solution to be used with nginx and the nginx auth_request module. It uses ECC public key signatures and cookies to authenticate users in an offline fashion, as far as the service provider is concerned.

With nginx-sso you can:

  • Authenticate users and check session validty
  • Authorize users to access specific resources
  • Provide authenticated information about the user to your backend application
  • Allow your application server to effectively stay offline

You can use it by deploying a single (static) binary and a config to a stock nginx instance.

Overview

nginx-sso works by creating a session cookie sso. This cookie contains information about the user, the expiry date of his session and the IP of the client which logged in. Furthermore, the cookie contains an ECDSA signature which protects the integrity of the payload during login. In our case, the ssologin tool has the necessary ECC private key and creates the cookie and the signature after a successful login.

The ssologin tool has to be customized to your own login architecture. It requires customization to accomodate your user-credential store (be it LDAP, htdigest, OAuth, homebrew). The common denominator is that it expects a non-empty string for the username and an optional group-string (comma-delimited). These two values will be encoded in the sso cookie.

Any service in the possession of the corresponding public key can then use the information stored in the sso cookie. With nginx-sso, this is done by the ssoauth tool. This tool is our authentication endpoint queried by nginx. The ssoauth tool takes the sso cookie, verifies its integrity and freshness (using the attached signature) and finally checks the username and groups against a list of ACL entries for different vhosts. If all of these checks pass, it will return the username, groups and expiry time of the cookie to the nginx frontend, which can pass it on to your application in the form of a plain HTTP header. Your application could then use this header to find the user in its own user database which could contain additional attributes (e.g. roles, contact info, etc).

More information can be found in the file TECHNICAL.md.

Building

For now, use the Makefile by calling make. The ssologin.go is meant to be an example on how to use the nginx-sso system to set the sso cookie during login.

Getting started

There is an example nginx.conf in etc/

  1. Start nginx: ~/local/sbin/nginx -c $PWD/etc/nginx.conf
  2. Generate a keypair using the ecc.go tool in tools/
  3. Start ssoauth: ./ssoauth -config etc/ssoauth.json
  4. Start ssologin: ./ssologin -config etc/ssologin.json
  5. Add login.domain.dev and auth.domain.dev to 127.0.0.1 to /etc/hosts
  6. Browse to http://username:[email protected]:8080/login
  7. Browse to http://auth.domain.dev:8080/secret

Contributing

nginx-sso is a work-in-progress and should not be used for production applications. It is the first application I've developed in golang. I'd like to get some help to improve the codebase and make it more adaptable to other setups. Please consider forking the repository and creating a pull-request on Github.

Author

nginx-sso was written by Johannes Gilger. Any additional contributors will be listed here.

License

nginx-sso is licensed under the GNU General Public License v2. See the file LICENSE for details.

nginx-sso's People

Contributors

heipei avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nginx-sso's Issues

trouble building

Hello,
I am really interested in trying out this software. looks like it could be a great way to authen/authorize webapps composed of static web and websockets all at one go!
However, i'm having trouble buidling. the error i see is:
$ make
go build ssoauth.go
ssoauth.go:30:2: cannot find package "github.com/Sirupsen/logrus" in any of:
/usr/lib/go/src/pkg/github.com/Sirupsen/logrus (from $GOROOT)
($GOPATH not set)
ssoauth.go:31:2: cannot find package "github.com/heipei/nginx-sso/ssocookie" in any of:
/usr/lib/go/src/pkg/github.com/heipei/nginx-sso/ssocookie (from $GOROOT)
($GOPATH not set)
make: *** [ssoauth] Error 1

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.