单点登录 - 关于CAS客户端的拦截请求和忽略/排除不需要拦截的请求URL的问题

本文探讨了如何在CAS客户端中处理请求URL的拦截与忽略问题。介绍了在CAS客户端3.3.x版本之后,通过修改AuthenticationFilter源码实现URL排除策略的方式,详细解析了`isRequestUrlExcluded`方法,以及`ignoreUrlPatternMatcherStrategyClass`参数的使用,为读者提供了一个实际配置示例。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 在《单点登录 - 自定义CAS客户端的过滤器AuthenticationFilter》https://my.oschina.net/thinwonton/blog/1439112 文章里,介绍了一种CAS客户端的拦截请求和忽略/排除不需要拦截的请求URL的方法,该方法需要改写原来的AuthenticationFilter类。

    后来无意中在网上看到了另一种方法,这好像是cas  clieng 3.3以后支持的方法,我们一起看一下AuthenticationFilter 源码。

    CAS CLIENT 3.2.1的源码

    public final void doFilter(final ServletRequest servletRequest, final ServletResponse servletResponse, final FilterChain filterChain) throws IOException, ServletException {
        final HttpServletRequest request = (HttpServletRequest) servletRequest;
        final HttpServletResponse response = (HttpServletResponse) servletResponse;
        final HttpSession session = request.getSession(false);
        final Assertion assertion = session != null ? (Assertion) session.getAttribute(CONST_CAS_ASSERTION) : null;

        if (assertion != null) {
            filterChain.doFilter(request, response);
            return;
        }

        final String serviceUrl = constructServiceUrl(request, response);
        final String ticket = CommonUtils.safeGetParameter(request,getArtifactParameterName());
        final boolean wasGatewayed = this.gatewayStorage.hasGatewayedAlready(request, serviceUrl);

        if (CommonUtils.isNotBlank(ticket) || wasGatewayed) {
            filterChain.doFilter(request, response);
            return;
        }

        final String modifiedServiceUrl;

        log.debug("no ticket and no assertion found");
        if (this.gateway) {
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值