LDAP + Kerberos authenticator for nginx's auth_request module.
Project description
nginx-krbauth
LDAP + Kerberos authenticator for nginx's auth_request module.
Installation
pip install git://github.com/quantum5/nginx-krbauth.git
Usage
Load nginx_krbauth:app into any WSGI compatible server.
Configuration is done through environment variables.
Example:
[uwsgi]
protocol = uwsgi
socket = /tmp/krbauth.sock
module = nginx_krbauth:app
env = KRB5_KTNAME=FILE:/home/krbauth/.keytab
env = KRBAUTH_HMAC_KEY=hunter2
env = KRBAUTH_LDAP_SERVER=ldapi:///
env = KRBAUTH_LDAP_BIND_DN=cn=http,ou=Apps,dc=example,dc=com
env = KRBAUTH_LDAP_BIND_AUTHTOK=hunter2
env = KRBAUTH_LDAP_SEARCH_BASE=dc=example,dc=com
nginx_krbauth exports two HTTP endpoints:
/krbauth: This endpoint performs SPNEGO authentication. When done, it sets a session cookie and generates a 307 redirect to the URL in thenextGET parameter./krbauth/check: The endpoint checks the validity of the session cookie. If valid, it returns 200. Otherwise, it returns 401.
The intention is to use /krbauth/check as auth_request in your nginx
configuration. On 401, nginx should be configured to generate a redirect to
/krbauth.
Configuration
KRB5_KTNAME: This is actually a Kerberos setting. It should point to a keytab file that only the user runningnginx_krbauthcan read containing the Kerberos host principals.KRBAUTH_HMAC_KEY(required): This is the HMAC key used to sign cookies. It should be a long random string. Keep it secret!KRBAUTH_KEY_DURATION: The duration (in seconds) for which the session cookie is valid. Default: 1 hour.KRBAUTH_RANDOM_SIZE: The length of the nonce in the session cookie in bytes. Default: 32.KRBAUTH_GSSAPI_NAME: The GSSAPI name for the service. Leave blank if any name in the keytab is fine.KRBAUTH_SECURE_COOKIE: This controls whether the session cookie is marked as HTTPS-only. Default: yes. Set to0ornoto disable.
LDAP
nginx_krbauth can also optionally check LDAP group membership. It does so by
looking up the groups of the LDAP entity whose krbPrincipalName attribute
matches the name of the Kerberos principal used to authenticate.
The group is specified through the WSGI environment variable
KRBAUTH_LDAP_GROUP. This could be set through uwsgi_param, for example.
The following environment variables are used to configure nginx_krbauth's
LDAP support:
KRBAUTH_LDAP_SERVER: The LDAP URI used to connect to the LDAP server.KRBAUTH_LDAP_SEARCH_BASE: The root of the subtree to search for LDAP entities forkrbPrincipalNameand group membership.KRBAUTH_LDAP_BIND_DN: The DN used to bind to the LDAP server. Leave blank for anonymous bind.KRBAUTH_LDAP_BIND_AUTHTOK: The password used to bind to the LDAP server. Leave blank for anonymous bind.
LDAP binding can also be used as a fallback authentication mechanism through HTTP Basic authentication. This is useful when SPNEGO is not supported, or when the client does not support Kerberos. To use this, configure:
KRBAUTH_LDAP_USER_DN: A string template to convert usernames into LDAP DNs. There should be one%ssymbol in this string, which will be replaced by the username.
Example nginx.conf
auth_request /krbauth/check;
error_page 401 = @krbauth;
location @krbauth {
return 307 /krbauth?next=$request_uri;
}
location /krbauth {
auth_request off;
error_page 527 error.html; # To cancel out error_page 401 outside.
uwsgi_pass unix:/tmp/krbauth.sock;
uwsgi_pass_request_body off;
uwsgi_param KRBAUTH_LDAP_GROUP "cn=group,dc=example,dc=com";
include uwsgi_params;
}
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file nginx_krbauth-0.0.1.tar.gz.
File metadata
- Download URL: nginx_krbauth-0.0.1.tar.gz
- Upload date:
- Size: 6.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ad301dbce5c923cc9a2307f4f3e79b025da9bb3463393b2438e3046b9492da45
|
|
| MD5 |
518546bbe6595d9a93c5b97e4c5e8784
|
|
| BLAKE2b-256 |
7cae04a815e12e16600483a56d5fea5f2c22b90a352baeadc19b209d9c4b36d0
|
File details
Details for the file nginx_krbauth-0.0.1-py3-none-any.whl.
File metadata
- Download URL: nginx_krbauth-0.0.1-py3-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.13.0 pkginfo/1.4.2 requests/2.21.0 setuptools/40.8.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
de8c5d1401fc3920e2e88bc121923a83ef9d1048da3c17ab33f33548838d12c3
|
|
| MD5 |
ed536b578431efc5a5d638f0733ef6ad
|
|
| BLAKE2b-256 |
a712d9c9419bda0a264f5a2231b40619df4a4dd73879eed5a8a2f63b56104250
|