SpringBoot项目集成cas单点登录
添加依赖
添加cas client依赖
<dependency> <groupId>net.unicon.cas</groupId> <artifactId>cas-client-autoconfig-support</artifactId> <version>2.2.0-GA</version> </dependency>
添加项目配置
cas: server-url-prefix: ${CAS_SERVER:undefined}/cas #cas认证中心地址 server-login-url: ${CAS_SERVER:undefined}/cas/login #cas认证中心登录地址 client-host-url: ${clientHostUrl:undefined} #后端服务地址
增加WebMvcConfiguration类
@Configuration public class WebMvcConfiguration extends WebMvcConfigurerAdapter{ @Override public void addCorsMappings(CorsRegistry registry){ registry.addMapping("/**") .allowedOrigins("*") .allowedHeaders("*") .allowedMethods("*").allowCredentials(true) .exposedHeaders(HttpHeaders.SET_COOKIE); } }
程序主函数添加注解
@ServletComponentScan
@EnableCasClient