nginx代理或nginx服务应用程序的身份验证守护程序
nginxauthdaemon的Python项目详细描述
用于NGIX代理或NGIX服务的认证守护进程。
安装和配置
- 为守护进程创建虚拟环境virtualenv env
- 使用. ./env/bin/activate 激活它
- 从pypipip install nginxauthdaemon 安装nginxauthdemon
- 创建配置文件覆盖默认值,请参阅[守护程序配置]。nb!为了安全起见,需要重写默认值SESSION_SALT、DES_IV和DES_KEY。
- setup env变量DAEMON_SETTINGS指向配置文件。
- 使用您喜爱的wsgi服务器运行daemon,例如gunicorn nginxauthdaemon:app。
- 更新nginx.conf。参见[nginx configuration]。
- 重新加载nginx(nginx -t reload)。
- 测试您的设置。
守护程序配置
基本配置属性是:
Option | Description |
---|---|
REALM_NAME | Realm name shown on login page |
SESSION_COOKIE | Session cookie name. Typically you do not need to change this. |
TARGET_HEADER | Header used to pass protected URL from NGINX |
SESSION_SALT | Long string used a salt for creation of session key. |
DES_IV | 8byte initial vector for DES algorithm |
DES_KEY | 8byte DES encryption key |
AUTHENTICATOR | Authenticator class name, by default ‘auth.DummyAuthenticator’ |
提供现成的身份验证器:
Authenticator name | Description |
---|---|
nginxauthdaemon.auth.DummyAuthenticator | Simplest authenticator checking username equals password |
nginxauthdaemon.crowdauth.CrowdAuthenticator | Atlassian Crowd based authenticator |
群组验证器有其他选项:
Option | Description |
---|---|
CROWD_URL | Crowd server URL, for ex ^{tt10}$ |
CROWD_APP_NAME | Crowd application name |
CROWD_APP_PASSWORD | Crowd application password |
nginx配置
你的nginx应该用ngx_http_auth_request_module编译。请使用nginx -V命令检查它。
配置示例:
upstream auth-backend { server 127.0.0.1:5000; } location = /auth/validate { internal; proxy_pass http://auth-backend; proxy_pass_request_body off; proxy_set_header Content-Length ""; } location = /auth/login { proxy_pass http://auth-backend; proxy_set_header X-Target $request_uri; } # Protected application location / { auth_request /auth/validate; # redirect 401 and 403 to login form error_page 401 403 =200 /auth/login; }
限制
守护进程可以扩展为支持LDAP或任何其他身份验证方法,但目前它只支持Atlassian群组。我很乐意将prs与新的auth方法合并。
许可证
参考实现受mit许可证约束。