ngx_lua_google_auth

目录

ngx_lua_google_auth

lua对nginx进行简单的Google身份验证

特点就是 直接在 nginx 上套 不需要自己开发服务 比较方便, 原理是 HTTP Basic Authorization 用户名就是自己配置的用户名 密码就填写 google authenticatio 生成的一次性 code 就好 支持多用户, ip 白名单。

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';
      
...
}
...
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

[0]  https://github.com/beyondblog/ngx_lua_google_auth

[0] 在Lua中编写nginx身份验证模块

[1] imzyxwvu / lua-gauth

[2] https://github.com/google/google-authenticator

随机文章