关于CAS4.0.0-RC3版本问题

本文总结了使用CAS认证系统4.0.0-RC3版本时遇到的问题,包括使用HTTP方式访问导致用户登录信息失效、配置域名后必须使用域名访问以及用户角色返回格式不一致等问题,并提供了相应的解决思路。

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

问题1:    

CAS4.0.0-RC3版本,在使用HTTP方式访问的时候,CAS服务端不会存储用户登录信息,所以用户登录后信息立刻失效,所以需要在CAS服务端安装证书,使用HTTPS方式访问(因为使用4.2.7版本没有这种问题,所以可能是版本问题吧...不过CAS最好还是使用HTTPS方式访问)

问题2:

在CAS服务端安装证书的时候会配置域名,配置了域名后,从客户端访问CAS服务端就必须使用域名访问,不能使用IP访问,否则cas服务端会认证不通过

问题3:

一般情况下,用户和角色的关系为多对多,所以需要在CAS服务端配置返回用户更多信息,并且返回多角色,但是当前用户为单角色和多角色,CAS服务端返回的数据格式是不一样的

eg: 当前用户为单角色时,方法this.getSubject().getPrincipals().asList().get(1);的返回值格式为

{role=role1,permission=permission1,...}

当前用户为多角色时,方法this.getSubject().getPrincipals().asList().get(1);的返回值格式为

{role=[role1,role2],permission=[permission1,permission2,permission3],...}

所以需要在客户端通过判断CAS服务端返回的数据格式,获取用户角色和权限以及其他信息

~~~以上为在开发过程中使用CAS时候遇到的坑,记录一下

这里的依赖有什么问题 :<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.guushine</groupId> <artifactId>cas-auth-server</artifactId> <version>1.0.0</version> <packaging>jar</packaging> <properties> <java.version>17</java.version> <spring-boot.version>3.4.4</spring-boot.version> <cas.version>7.2.5</cas.version> </properties> <dependencyManagement> <dependencies> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-support-bom</artifactId> <version>${cas.version}</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement> <dependencies> <!-- Spring Boot Starter --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-web</artifactId> <version>${spring-boot.version}</version> </dependency> <!-- CAS Server Core --> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-webapp</artifactId> </dependency> <!-- CAS Server SAML Support --> <!-- <dependency>--> <!-- <groupId>org.apereo.cas</groupId>--> <!-- <artifactId>cas-server-support-saml</artifactId>--> <!-- </dependency>--> <!-- CAS Server OAuth2 Support --> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-support-oauth</artifactId> </dependency> <!-- CAS Server OIDC Support --> <dependency> <groupId>org.apereo.cas</groupId> <artifactId>cas-server-support-oidc</artifactId> </dependency> <!-- Oracle JDBC --> <dependency> <groupId>com.oracle.database.jdbc</groupId> <artifactId>ojdbc8</artifactId> <version>19.3.0.0</version> </dependency> <!-- Spring Data JPA --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-data-jpa</artifactId> <version>${spring-boot.version}</version> </dependency> <!-- Thymeleaf --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!-- Spring Security --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-security</artifactId> <version>${spring-boot.version}</version> </dependency> <!-- 测试依赖 --> <dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-test</artifactId> <scope>test</scope> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> <version>${spring-boot.version}</version> </plugin> </plugins> </build> </project>
最新发布
07-09
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值