Coder Social home page Coder Social logo

authproxy's Introduction

OAuth 2 Reverse Proxy

Secure administration panels via a single authentication point using Google as OAuth provider.
It handles multiple domains and multiple backends at once, taking care of forwarding proper HTTP headers (X-Forwarded-For / Proto) and introducing X-Forwarded-User.
Also supports Google Apps domains.

Setting up

Follow these steps to get a 'Project' setup.
Set the 'Authorized Redirect URI' to http://<secured_domain>/authproxy/google/return

Save the 'Client ID' and 'Client Secret', they will be required to setup the proxy. The configuration looks like:

[server]
bind_ip = "0.0.0.0"
bind_port = 80
# change this
cookie_secret = "monstah"
# google apps domain, or leave it blank
auth_domain = "mysite.com"

[domains]
  [domains.example1]
  host = "admin.mysite.com"
  upstream = ["internal1.mysite.com", "internal2.mysite.com:8080"]
  client_id = "__clientID__"
  client_secret = "TWWWWz-EWWWWlxfX"

  # multiple domains
  [domains.example2]
  host = "admin.secondsite.com"
  upstream = ["internal3.mysite.com"]
  client_id = "__clientID__"
  client_secret = "TWWWWz-EWWWWlxfX"

Authproxy takes over the following routes; these will not be proxied to your application:

Login http://<secured_domain>/authproxy/google
Callback URL http://<secured_domain>/authproxy/return
User Check http://<secured_domain>/authproxy/user

A more complex deployment

Separate public site from administration via domain names. Ex: www.mysite.com (public) admin.mysite.com (private).

                      +---------------+         
                      |               |         
admin.mysite.com      |               |         
            +---------+    client     |         
            |         |               |         
            |         |               |         
            |         +-------+-------+         
            |                 |                 
            |                 |                 
    +-------v-------+         |                 
    |               |         |                 
    |               |         |                 
    |  authproxy    |         |   www.mysite.com
    |               |         |                 
    |               |         |                 
    +-------+-------+         |                 
            |                 |                 
            |                 |                 
            |         +-------v-------+         
            |         |               |         
            |         |               |         
            +---------+    site       |         
                      |               |         
                      |               |         
                      +---------------+         

This way you can either:

  • Create 2 DNS entries, one for public (pointing to backends) and one for private (pointing to authproxy).
  • Chain requests from a load-balancer, splitting public/private sites based on HTTP Host header.

Rails

Use hostname constraint in your routes.

match '/admin' => 'secret_stuff#index', :constraints => { :subdomain => 'admin' }

About headers...

node's http-proxy library downcase all headers prior forwarding. This works fine with most frameworks/http servers, but it is worth mentioning ;)

Authors

@lxfontes

Credits

Inspired by bitly's google-auth-proxy and doorman.

License

MIT

authproxy's People

Contributors

lxfontes avatar

Stargazers

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