单点登录cas客户端配置

本文详细介绍了如何配置CAS客户端,包括在web项目中添加依赖和配置web.xml,在springboot项目中配置依赖与application.yml,以及提供相关资料的下载链接。
摘要由CSDN通过智能技术生成

一,web项目配置

添加依赖

<!-- cas client -->
<dependency>
    <groupId>org.jasig.cas.client</groupId>
    <artifactId>cas-client-core</artifactId>
    <version>3.4.1</version>
</dependency>

web.xml 配置

<listener>
    <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class>
</listener>
<filter>
    <filter-name>CAS Single Sign Out Filter</filter-name>
    <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class>
    <init-param>
        <param-name>casServerUrlPrefix</param-name>
        <param-value>http://${cas.host}/cas/</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>CAS Single Sign Out Filter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<filter>
    <filter-name>CASFilter</filter-name>
    <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class>
    <init-param>
        <param-name>casServerLoginUrl</param-name>
        <param-value>http://${cas.host}/cas/login</param-value>
    </init-param>
    <init-param>
        <param-name>serverName</param-name>
        <param-value>http://${cas.host}</param-value>
    </init-param>
    <init-param>
        <param-name>useSession</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>redirectAfterValidation</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>CASFilter</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>
<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>http://${cas.host}/cas/</param-value>
    </init-param>
    <init-param>
        <param-name>serverName</param-name>
        <param-value>http://${cas.host}</param-value>
    </init-param>
</filter>
对应我本人上传的cas server开发的版本。 <!-- CAS logout--> <bean id="logout" class="org.apache.shiro.web.filter.authc.LogoutFilter"> <property name="redirectUrl" value="${cas.logout.url}"/> </bean> <!-- CAS认证过滤器 --> <bean id="casFilter" class="org.apache.shiro.cas.CasFilter"> <property name="failureUrl" value="${adminPath}/login"/> </bean> <!-- 安全认证过滤器 --> <bean id="shiroFilter" class="org.apache.shiro.spring.web.ShiroFilterFactoryBean"> <property name="securityManager" ref="securityManager" /> <!-- CAS --> <property name="loginUrl" value="${cas.server.url}?service=${cas.project.url}${adminPath}/cas" /> <!-- CAS --> <property name="successUrl" value="${adminPath}?login" /> <property name="filters"> <map> <entry key="cas" value-ref="casFilter"/> <entry key="authc" value-ref="formAuthenticationFilter"/> <!-- CAS --> <entry key="logout" value-ref="logout" /> <entry key="changePassword" value-ref="changePassword" /> <entry key="clearUser" value-ref="clearUser" /> </map> </property> <property name="filterChainDefinitions"> <ref bean="shiroFilterChainDefinitions"/> </property> </bean> 然后在核心应用配置文件中加入以下三个地址: #cas.server.url=https://zhang.com:8443/CasServer cas.server.url=http://127.0.0.1:8088/CasServer cas.project.url=http://127.0.0.1:8080/NX_IMP #cas.logout.url=https://zhang.com:8443/CasServer/logout?server=http://localhost:8080/NX_IMP cas.logout.url=http://127.0.0.1:8088/CasServer/logout?server=http://127.0.0.1:8080/NX_IMP 分别是cas 服务的地址,自己应用的地址,和注销登录的地址。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值