微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

会话超时/会话以 Openresty 和 Keycloak 中的 lua-resty-openidc 结束

如何解决会话超时/会话以 Openresty 和 Keycloak 中的 lua-resty-openidc 结束

我正在尝试使用 OpenResty Nginx 服务器配置 lua-resty-openidc。 使用网站身份验证。

有谁知道,我是否可以让会话结束或强制客户端刷新令牌?

我通过在身份验证系统 Keycloak 中结束会话进行了测试,没有任何反应,用户仍然可以访问,停留在网站上,不需要重新进行身份验证。

access_by_lua '
    local opts = {          
            redirect_uri = "https://domain/redirect_uri",accept_none_alg = true,discovery = "https://a.domain/auth/realms/realm/.well-kNown/openid-configuration",client_id = "CLIENT",client_secret = "SEEECREET",redirect_uri_scheme = "https",logout_path = "/logout",redirect_after_logout_uri = "https://a.domain/auth/realms/realm/protocol/openid-connect/logout?redirect_uri=https://www.domain",redirect_after_logout_with_id_token_hint = false,session_contents = {id_token=true},access_token_expires_in = 3600,renew_access_token_on_expiry = true 
        }
        -- call introspect for OAuth 2.0 Bearer Access Token validation                         
        local oidc = require("resty.openidc")
        local res,err = oidc.authenticate(opts)

        -- deal with err not being nil
        if err then
            ngx.status = 500
            ngx.say(err)
            ngx.exit(ngx.HTTP_INTERNAL_SERVER_ERROR)
        end
        
        
        if  (res.id_token.roles == nil or res.id_token.roles == "") then
            ngx.log(ngx.INFO,"No Roles,therefore denied access to " .. res.id_token.preferred_username)   
            ngx.exit(ngx.HTTP_FORBIDDEN)
        end
        
        
        if not string.find(res.id_token.roles,"searchRole") then   
            ngx.log(ngx.INFO,"Denied acces to " .. res.id_token.preferred_username)                    
            ngx.exit(ngx.HTTP_FORBIDDEN)
        end         

  ';

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。