1、创建springboot项目后在pom中添加
<dependency>
<groupId>net.unicon.cas</groupId>
<artifactId>cas-client-autoconfig-support</artifactId>
<version>2.1.0-GA</version>
</dependency>
2、 在application.yml中添加
cas:
server-login-url: http://localhost:8080/cas/login
server-url-prefix: http://localhost:8080/cas
client-host-url: http://localhost:8081
validation-type: cas3
3、在启动类添加注解@EnableCasClient
@SpringBootApplication
@EnableCasClient
public class DemoApplication {
public static void main(String[] args) {
SpringApplication.run(DemoApplication.class, args);
}
}
4、在springboot中创建controller 添加如下方法
@GetMapping("/test")
public String test(){
return "test....";
}
5、按以上步骤在创建一个springboot改动下端口和访问接口启动
6、启动cas服务、启动两个springboot,访问其中的localhost:8082/test就会跳转到cas认证页面,输入正确账号密码登陆后自动跳转到test,而另外一个springboot的接口不需要验证cas就可以直接访问
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)