很抱歉迟到了,但我实际上做了一个 quarkus - apareo cas 整合。基本上我添加了 quarkus-undertow 扩展,以便能够使用 src/main/resources/META-INF/web.xml。我还使用 org.jasig.cas.client:cas-client-core:3.6.1 来拥有 cas 过滤器。我的 web.xml 包含这样的内容:
<context-param>
<param-name>serverName</param-name>
<param-value>${cas.redirect.url}</param-value>
</context-param>
<filter>
<filter-name>CAS Authentication Filter</filter-name>
<filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
<init-param>
<param-name>casServerLoginUrl</param-name>
<param-value>${cas.login.url}</param-value>
</init-param>
<init-param>
<param-name>ignorePattern</param-name>
<param-value>/proxy/</param-value>
</init-param>
<init-param>
<param-name>ignoreUrlPatternType</param-name>
<param-value>CONTAINS</param-value>
</init-param>
<async-supported>true</async-supported>
</filter>
<filter>
<filter-name>CAS Validation Filter</filter-name>
<filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class>
<init-param>
<param-name>casServerUrlPrefix</param-name>
<param-value>${cas.base.url}</param-value>
</init-param>
<async-supported>true</async-supported>
</filter>
<filter>
<filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
<filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>CAS Authentication Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CAS Validation Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<filter-mapping>
<filter-name>CAS HttpServletRequest Wrapper Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
Saml 集成类似,只需使用 SAML 过滤器。有关配置选项的更多信息,请参阅java-cas-client
题外话,为什么需要通过 CAS 对 API 进行身份验证?它会将您重定向到该 CAS 登录窗口,然后将您重定向回来。您不能通过邮递员或 curl 使用此 API。此外,API 不存储有关用户的任何会话,因此每次都会发生这种重定向舞蹈。这不是保护 API 的方式。网页或网络应用程序是的,但不是 API。