【问题标题】:Optional or anonymous authentication with mod_auth_openidc使用 mod_auth_openidc 进行可选或匿名身份验证
【发布时间】:2019-06-11 07:29:24
【问题描述】:

是否有可能在 mod_auth_openidc 中做相当于 prompt=none 尝试使用来自已登录用户的凭据访问受保护的网站,但如果不是,则回退到允许未经身份验证的访问?

我运行的网站无需任何身份验证即可供公众访问,但也为已登录的用户提供额外的可选功能。我想使用 mod_auth_openidc 来允许用户登录,但如果我使用模块保护我的页面,它会在访问页面之前强制登录(如您所料),如果我不保护我的页面,那么即使我已经登录,我也看不到 OIDC 变量。

因此,您将访问该网站并查看主页。该页面上有一个登录按钮。登录时,您仍在主页上,但现在您会看到额外的内容(例如个性化的欢迎信息)。

到目前为止,我唯一的解决方案是让我的整个网站在两个不同的 url 上可用,一个受 openidc 保护,一个不受保护。当您登录时,您将被重定向到另一个站点。但这可能会使用户感到困惑,甚至会混淆需要配置 baseURL 的服务器端软件。

我可以通过其他方式轻松实现这一点,但我找不到基于 mod_auth_openidc 模块的解决方案。

我试过了:

<Location /example/public>
   AuthType openid-connect
</Location>
<Location /example/protected/>
   AuthType openid-connect
   Require valid-user
</Location>

我希望会发生的是,转到 /example/protected 将需要我登录(它确实如此),然后返回 /example/public 仍然会知道我已登录。但是尽管 /example /protected 工作得很好(所以我的基本设置是正确的), /example/public 根本不起作用 - 没有设置变量,所以我仍然没有登录。

是否有一个 Require 选项可以满足我的要求,或者其他一些干净的答案?

【问题讨论】:

    标签: mod-auth-openidc


    【解决方案1】:

    你需要使用OIDCUnAuthAction pass,见:https://github.com/zmartzone/mod_auth_openidc/commit/6890b13c481f12debbd7c65a79e9dc5197deb794

    # Defines the action to be taken when an unauthenticated request is made.
    # "auth" means that the user is redirected to the OpenID Connect Provider or Discovery page.
    # "401" means that HTTP 401 Unauthorized is returned.
    # "410" means that HTTP 410 Gone is returned
    # "pass" means that an unauthenticated request will pass but claims will still be passed when a user happens to be authenticated already
    # Useful in Location/Directory/Proxy path contexts that serve AJAX/Javascript calls and for "anonymous access"
    # When not defined the default "auth" is used.
    #OIDCUnAuthAction [auth|pass|401|410]
    

    【讨论】:

    • 非常感谢。这正是我所需要的。我正在查看完全错误的文档。问题解决了。
    猜你喜欢
    • 1970-01-01
    • 2021-04-28
    • 2021-11-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-14
    • 1970-01-01
    • 2016-08-08
    相关资源
    最近更新 更多