一、依赖dependency groupIdorg.jasig.cas.client/groupId artifactIdcas-client-support-springboot/artifactId version3.6.4/version /dependency二、yml配置cas: server-url-prefix: https://xxx.xxx:8443/cas 改成cas服务端地址 server-login-url: https://xxx.xxx:8443/cas/login 改成cas服务端地址 client-host-url: http://127.0.0.1:18082 改成你们自己的地址cas登录后显示地址 validation-type: CAS3 authentication-url-patterns: - /auth/* 改成你们自己的用于拦截接口三、获取用户idGetMapping(value /hello) ResponseBody public String hello(HttpSession session){ Assertion assertion (Assertion) session.getAttribute(CONST_CAS_ASSERTION); AttributePrincipal principal assertion.getPrincipal(); String userId principal.getName(); System.out.println(userId: userId); return hello world userId; }四、springboot启动类 增加 EnableCasClient