ngx_lua_google_auth
目录
ngx_lua_google_auth
lua对nginx进行简单的Google身份验证
特点就是 直接在 nginx 上套 不需要自己开发服务 比较方便, 原理是 HTTP Basic Authorization 用户名就是自己配置的用户名 密码就填写 google authenticatio 生成的一次性 code 就好 支持多用户, ip 白名单。
1 如何使用
1.1 概要
modify nginx.conf file
...
http {
...
lua_package_path '/usr/local/lualib/?.lua;/YOU_PATH/conf/ngx_lua_google_auth/?.lua;';
init_by_lua_file /YOU_PATH/conf/ngx_lua_google_auth/init.lua;
...
}
...
server {
access_by_lua_file '/YOU_PATH/conf/ngx_lua_google_auth/access.lua';
...
}
...
1.2 配置
edit /YOU_PATH/conf/ngx_lua_google_auth/config.lua
-- auth router
auth_url = "/auth/"
-- ip white list
ip_white_list = {"10.10.1.1"}
-- signature
signature = "ngx_lua_google_auth"
-- user list
users = {}
users["beyondblog"] = "BHSOTR7UKYQWU5NJ"
-- `beyondblog` is auth users , key is the value.
-- `BHSOTR7UKYQWU5NJ` is google authenticator secret
$ nginx -t
$ nginx -s reload
2 参考
[0] https://github.com/beyondblog/ngx_lua_google_auth
[2] https://github.com/google/google-authenticator