lua-resty-auth

一个用于 HTTP 认证的 Lua resty 模块(支持基本和摘要方案,参考 RFC 2617)

$ opm get duhoobo/lua-resty-auth

lua-resty-auth

一个用于 HTTP 认证的 Lua resty 模块(支持基本和摘要方案,参考 RFC 2617)。

待办事项

  • 用于 basic 方案的 md5crpyt

  • 用于 basic 方案的 crypt

  • 测试用例

  • 压力测试

  • 安全审计

缺失的功能

  • qop 选项 auth-int

  • 算法 MD5-sess

使用示例

    lua_shared_dict nonce 2m;

    init_by_lua '
        local auth = require("resty.auth")

        local ok, msg = auth.setup {
            scheme= "digest", 
            shm= "nonce", 
            user_file= "htdigest",
            expires= 10,
            replays= 5,
            timeout= 10,
        }
        if not ok then error(msg) end

        local ok, msg = auth.setup {
            scheme= "basic", 
            user_file= "htpasswd"
        )
        if not ok then print msg end
    ';

    server {
        location /auth_basic/ {
            access_by_lua '
                local auth = require("resty.auth")
                auth.new("basic", "you@site"):auth()
            ';
        }

        location /auth_digest/ {
            access_by_lua '
                local auth = require("resty.auth")
                auth.new("digest", "you@site"):auth()
            ';
        }
    }

致谢

作者

杜洪普 (duhoobo)

许可证

2bsd

依赖

nginx

版本