費勁千辛萬苦開發出來的系統要接入sso 讓我頭大還好有大佬幫忙session
首先在配置文件中寫入啓動的ip地址app
HOST=http://127.0.0.1:8080/ 地址寫你的地址和端口
而後在pom文件中導入cas-client包用來鏈接cas的server端口url
<dependency> <groupId>org.jasig.cas.client</groupId> <artifactId>cas-client-core</artifactId> <version>3.5.1</version> </dependency>
而後在配置文件中進行配置spa
<!-- cas監聽 --> <listener> <listener-class>org.jasig.cas.client.session.SingleSignOutHttpSessionListener</listener-class> </listener> <!-- 監聽結束--> <!--cas配置開始--> <filter> <filter-name>CasSingleSignOutFilter</filter-name> <filter-class>org.jasig.cas.client.session.SingleSignOutFilter</filter-class> <init-param> <param-name>casServerUrlPrefix</param-name> <param-value>http://sso.caicaivip.com/</param-value> // 你的 sso服務端地址 </init-param> </filter> <filter-mapping> <filter-name>CasSingleSignOutFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CasAuthenticationFilter</filter-name> <filter-class>org.jasig.cas.client.authentication.AuthenticationFilter</filter-class> <init-param> <param-name>casServerLoginUrl</param-name> <param-value>http://sso.caicaivip.com/login</param-value> // 服務端口的登陸接口 </init-param> <init-param> <param-name>serverName</param-name> <param-value>${HOST}</param-value> </init-param> <init-param> <param-name>ignorePattern</param-name> <param-value>/status</param-value> </init-param> </filter> <filter-mapping> <filter-name>CasAuthenticationFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CasValidationFilter</filter-name> <filter-class>org.jasig.cas.client.validation.Cas20ProxyReceivingTicketValidationFilter</filter-class> <init-param> <param-name>casServerUrlPrefix</param-name> <param-value>http://sso.caicaivip.com/</param-value> //server地址 </init-param> <init-param> <param-name>serverName</param-name> <param-value>${HOST}</param-value> </init-param> <init-param> <param-name>redirectAfterValidation</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>CasValidationFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>CasHttpServletRequestWrapperFilter</filter-name> <filter-class>org.jasig.cas.client.util.HttpServletRequestWrapperFilter</filter-class> </filter> <filter-mapping> <filter-name>CasHttpServletRequestWrapperFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <!--cas配置結束-->
而後就能夠啓動接入你的sso的服務端口了code