1

是否可以在 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 选项可以做我想要的,或者其他一些干净的答案?

4

1 回答 1

0

您需要使用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]
于 2019-06-11T17:58:57.277 回答