如何在 Apache 反向代理后面的 Quarkus 中使用 OIDC_CLAIM_* 标头?

How to use OIDC_CLAIM_* headers in Quarkus behind an Apache Reverse Proxy?

提问人:Vinetos 提问时间:6/1/2023 最后编辑:Hans Z.Vinetos 更新时间:9/10/2023 访问量:83

问:

我在 Apache 反向代理后面运行 Quarkus。
Apache 用于对用户进行身份验证,并将 HTTP 标头传递给后面的应用程序。
mod_auth_openidcOIDC_CLAIM_*

如何配置Quarkus读取HTTP头?有没有办法以“夸克”的方式@Inject这一点?OIDC_CLAIM_*

以下是相关的 HTTPD 配置:

<Location /java>
   ProxyPreserveHost On
   AuthType openid-connect
   Require claim resource_access.apache-oidc.roles:admin-role

   ProxyPass "http://java-app:8080"
   ProxyPassReverse "http://java-app:8080"
</Location>

实际上,我发现使用的唯一方法@HeaderParam

@GET
public String get(@HeaderParam("OIDC_CLAIM_preferred_username") String username) {
     return username;
}

它有效,但不是它应该的方式。我可以使用 Quarkus 检索标头并通过 CDI 访问其内容吗?OIDC_*

谢谢

java apache openid-connect quarkus mod-auth-openidc

评论

0赞 Lucas Declercq 6/1/2023
您应该使用 ContainerRequestFilter 手动读取标头,并设置安全上下文和/或包含所需值的 RequestScoped 自定义 Bean。你可以从这篇文章中获得灵感:stackoverflow.com/questions/66695265/...

答: 暂无答案