
1、创建springboot项目后在pom中添加
net.unicon.cas cas-client-autoconfig-support2.1.0-GA
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就可以直接访问
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)