当前位置:网站首页>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
边栏推荐
- 基于CAS的SSO单点客户端配置
- Kubernetes----Pod配置资源配额
- Some lightweight network models in detection and segmentation (share your own learning notes)
- UE4 smart pointer and weak pointer
- When AI encounters life and health, Huawei cloud builds three bridges for them
- 中部“第一城”,长沙“人才引力”从争先到领先
- [ostep] 03 virtualized CPU - restricted direct execution mechanism
- Wechat applet - "do you really understand the use of applet components?
- One stop monitoring of the software and hardware infrastructure of the whole university, and Suzhou University replaces PostgreSQL with time series database
- 目标跟踪相关知识总结
猜你喜欢
随机推荐
"Baget" takes you one minute to build your own private nuget server
Error reported by Nacos enabled client
Lingo软件的使用
When AI encounters life and health, Huawei cloud builds three bridges for them
[GYCTF2020]FlaskApp
如何做 APP 升级测试 ?
Devops system of "cloud native" kubesphere pluggable components
【方差分析】之matlab求解
【深度学习】全连接网络
Plato Farm有望通过Elephant Swap,进一步向外拓展生态
First knowledge of opencv4.x --- image perspective transformation
Flask send_ Absolute path traversal caused by file function
多线程——线程池
TDengine 助力西门子轻量级数字化解决方案 SIMICAS 简化数据处理流程
How to do app upgrade test?
Low power multi-channel wfas1431 wireless data acquisition and transmission instrument operation process description
堆叠降噪自动编码器 Stacked Denoising Auto Encoder(SDAE)
【常微分方程求解及绘图之求解小船行走轨迹】
Install dexdump on win10 and remove the shell
C common function integration







![[untitled]](/img/50/7aa01f1d8657700a11cbc26290804a.png)

