Giter VIP home page Giter VIP logo

nginx-auth-cas-lua's Introduction

nginx-auth-cas-lua

WARNING, CAS integration is functional, but mileage may vary.

This is a CAS client written entirely using nginx's lua module. It is similar to apache mod_auth_cas.

Installation

Install dependencies

apt install libnginx-mod-http-lua

or

yum install nginx-mod-http-lua

mkdir -p /etc/nginx/lua/resty
cd /etc/nginx/lua/resty/
wget https://raw.githubusercontent.com/ledgetech/lua-resty-http/master/lib/resty/http_headers.lua
wget https://raw.githubusercontent.com/ledgetech/lua-resty-http/master/lib/resty/http.lua

Install nginx-auth-cas-lua

cd /etc/nginx/lua/
wget https://raw.githubusercontent.com/prigaux/nginx-auth-cas-lua/master/src/cas.lua
wget https://raw.githubusercontent.com/prigaux/nginx-auth-cas-lua/master/src/global_cas_conf.lua

Configuration

  • configure cas_uri in /etc/nginx/lua/global_cas_conf.lua
  • configure various global stuff in nginx config
# needed for resty.http
resolver 8.8.8.8;
lua_ssl_trusted_certificate /etc/ssl/certs/ca-certificates.crt;

lua_package_path '/etc/nginx/lua/?.lua;;';
lua_shared_dict cas_store 10M;
  • protect a location (REMOTE_USER is passed to proxy implicitly):
location /secured {
    access_by_lua_block { require('cas').forceAuthentication() }
    proxy_pass ...;
    ...
}

NB: access_by_lua_block must be before proxy_pass

  • or for FASTCGI protect a location and provide REMOTE_USER explicitly:
    location /secured {
      access_by_lua_block { require('cas').forceAuthentication() }
      fastcgi_pass ...;
      fastcgi_param REMOTE_USER $http_remote_user;
      ...
    }
    

Known limitations

  • only CAS protocol v2
  • no CAS proxy
  • no CAS single sign out

Various information

  • this work is based on Toshi Piazza's ngx-http-cas-client-lua
  • we could be using ngx.location.capture, but it does not work with HTTP/2.
  • with apache mod_auth_cas, you can not protect both in apache and in backend: mod_auth_cas will always validate the ticket, even if its session is valid. The current nginx-auth-cas-lua code does not have this limitation. NB: if the backend ask for proxy tickets, either use a different url to receive pgtIou, or use
if ($remote_addr !~ "^192[.]168[.]1[.](56|57)$") { # if request is from CAS, let it go to the backend unauthenticated (needed for pgtIOU)
    access_by_lua_block { require('cas').forceAuthentication() }
}

nginx-auth-cas-lua's People

Contributors

prigaux avatar jb-leger avatar dodok1 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.