当前位置:网站首页>CAS based SSO single point client configuration
CAS based SSO single point client configuration
2022-07-26 14:40:00 【Xiang wants to】
be based on CAS Of SSO Single point client configuration
Related articles :
After creating the server , Then create the client , Test the server
1、 initialization SpringBoot project
When initializing , Check spring web service , It can also be built directly maven service
<dependency>
<groupId>net.unicon.cas</groupId>
<artifactId>cas-client-autoconfig-support</artifactId>
<version>2.3.0-GA</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
maven Friends whose foundation is not solid enough , Still recommended IDEA Bring your own spring Initial chemical tool , Create two projects , Namely web-client-01 and web-client-02
2、 Write code
stay SpringBoot Add on startup class @EnableCasClient Turn on CAS


Namely webClient01Application、webClient02Application
To save space , I will only list an example of the following configuration , Read the text carefully
1、 Add configuration information
server:
port: 9093
cas:
server-login-url: http://localhost:9101/cas/login # CAS Service login address
server-url-prefix: http://localhost:9101/cas # CAS service
client-host-url: http://localhost:9093 # The local service
validation-type: cas3 # Encryption type
The two services are used separately 9092、9093 port ,CAS Service login address 、CAS The service and encryption types are consistent , That is, the port address we configured before , Jump address :, Only the local service port should be flexibly configured
2、 add to Controller
Both services add this controller
import org.jasig.cas.client.authentication.AttributePrincipal;
import org.jasig.cas.client.validation.Assertion;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpSession;
import static org.jasig.cas.client.util.AbstractCasFilter.CONST_CAS_ASSERTION;
@RestController
public class Controller {
@RequestMapping("/sso-test1")
public String test1(HttpSession session){
Assertion assertion = (Assertion)session.getAttribute(CONST_CAS_ASSERTION);
AttributePrincipal principal = assertion.getPrincipal();
String loginName = principal.getName();
return "sso-test1, Current login account "+loginName;
}
}
It's all set up here
3、 Start the client service
Access address :
http://localhost:9092/sso-test1
You will find that the page directly jumps to the login page

We fill in the configured server user name and password

Click to log in

Let's test the single point effect , visit
http://localhost:9093/sso-test2

It is as expected , Single sign on simulation succeeded ! Finally, let's show Code structure of client

The client code is too simple , I won't upload it GitHub 了 , If you want a little partner, you can contact Ben Up. Finally, I wish you all find your favorite job
Finally, let's pay attention 
Focus on 『Xiang Want to 』 official account
边栏推荐
- Seata deployment and microservice integration
- As the "first city" in Central China, Changsha's "talent attraction" has changed from competition to leadership
- Wechat applet - "do you really understand the use of applet components?
- 『云原生』KubeSphere可插拔组件之DevOps系统
- 网络图片转本地导致内核退出
- 填问卷,领奖品 | 诚邀您填写 Google Play Academy 活动调研问卷
- 【文件上传漏洞-06】分布式配置文件攻击实验—以upload-labs-4为例
- 注解和反射
- [untitled]
- Instructions for various interfaces of hand-held vibrating wire collector vh03
猜你喜欢

~6. CCF 2021-09-1 array derivation

图神经网络Core数据集介绍

作业7.25 排序与查找
![[untitled]](/img/50/7aa01f1d8657700a11cbc26290804a.png)
[untitled]

One stop monitoring of the software and hardware infrastructure of the whole university, and Suzhou University replaces PostgreSQL with time series database

Embedded development: skills of debugging embedded software

如何评价测试质量?

VP video structured framework

VBA 上传图片

创建Root权限虚拟环境
随机推荐
图神经网络Core数据集介绍
Pdf translation, which translation company in Beijing is good
我的创作纪念日-从心出发
Mysql-03 database operation
Maya imports the model into unity
URL的使用下载资源
Instructions for various interfaces of hand-held vibrating wire collector vh03
When AI encounters life and health, Huawei cloud builds three bridges for them
如何评价测试质量?
Embedded development: skills of debugging embedded software
10 schemes to ensure interface data security
VP video structured framework
win10安装Dexdump并脱壳
创建Root权限虚拟环境
智能家居行业发展,密切关注边缘计算和小程序容器技术
Use cpolar to build a commercial website (apply for website security certificate)
【干货】MySQL索引背后的数据结构及算法原理
C语言入门必刷100题合集之每日一题(1-20)
Tips for unity transparent channel
WPF 常用功能整合