SpringBoot项目集成cas单点登录

添加依赖

添加cas client依赖

        
            net.unicon.cas
            cas-client-autoconfig-support
            2.2.0-GA
        

添加项目配置

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

 

转载于:https://www.cnblogs.com/jugglee/p/10564993.html

你可能感兴趣的:(SpringBoot项目集成cas单点登录)