安装配置CAS server

来源:互联网 发布:淘宝卖家体检中心在哪 编辑:程序博客网 时间:2024/05/02 00:21


Maven的CAS服务端模板,在这个基础上修改配置文件,作为CAS的服务端

下载地址:https://github.com/UniconLabs/simple-cas4-overlay-template


以下是需要修改的:


1、pom.xml

保留的插件

maven-war-plugin

maven-compiler-plugin


保留的依赖

cas-server-support-rest

cas-server-support-jdbc

cas-server-webapp

c3p0 可选

mysql-connector-java

cas-management-webapp 这个暂时还没弄懂


2、web.xml

添加的filter:

一是CorsFilter:解决WEB端与CAS端跨域问题


    <filter>        <filter-name>CorsFilter</filter-name>        <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>CorsFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>


3、\src\main\webapp\WEB-INF\spring-configuration\propertyFileConfigurer.xml

WINDOWS系统需要把cas.properties和log4j2.xml手动拷贝到WEB服务器上,把路径加入到下边的location中。linux中是/etc/cas/cas.properties


<util:properties id="casProperties" location="file:D:\apache-tomcat-8.0.28\webapps\etc\cas\cas.properties" /><context:property-placeholder properties-ref="casProperties" />

4、把一下三个SAML相关的文件删除,因为我们不用安全断言标记语言

src\main\webapp\WEB-INF下的cas-servlet-saml.xml

src\main\webapp\WEB-INF\spring-configuration\argumentExtractorsConfiguration.xml

src\main\webapp\WEB-INF\spring-configuration\uniqueIdGenerators.xml


5、加入以下两个文件

src\main\webapp\WEB-INF\deployerConfigContext.xml

这里配置JDBC数据源、连接池等,以及注册被保护的服务registeredServicesList


<util:list id="registeredServicesList">    <bean class="org.jasig.cas.services.RegexRegisteredService"         p:id="1"         p:name="HTTPS and IMAPS services on example.com"         p:serviceId="http.*.+"         p:evaluationOrder="0"/></util:list>


src\main\webapp\WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml
其中一个Bean名字是ticketGrantingTicketCookieGenerator,它的属性cookieSecure="false"表示使用http,true表示使用https
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"                p:cookieSecure="false"                p:cookieMaxAge="-1"                p:cookieName="TGC"                p:cookiePath="/cas" />
将参数p:cookieSecure="true"改为p:cookieSecure="false",同理为HTTPS验证相关,TRUE为采用HTTPS验证,与deployerConfigContext.xml的参数保持一致。参数p:cookieMaxAge="-1",简单说是COOKIE的最大生命周期,-1为无生命周期,即只在当前打开的IE窗口有效,IE关闭或重新打开其它窗口,仍会要求验证。可以根据需要修改为大于0的数字,比如3600等,意思是在3600秒内,打开任意IE窗口,都不需要验证。

6、把web.xml中的这个删除,因为不用saml
<servlet-mapping>    <servlet-name>cas</servlet-name>    <url-pattern>/samlValidate</url-pattern></servlet-mapping>

7、这样我们的CAS服务已经配置好了,打包,把war包放在tomcat下,启动。


8、此时我们的应用就可以访问CAS服务进行认证了,默认的获取TGT的url是http://ip:8080/cas/v1/tickets

获取ST的url是上个接口返回的,并且带有TGT参数。




Maven的CAS服务端模板,在这个基础上修改配置文件,作为CAS的服务端

下载地址:https://github.com/UniconLabs/simple-cas4-overlay-template


以下是需要修改的:


1、pom.xml

保留的插件

maven-war-plugin

maven-compiler-plugin


保留的依赖

cas-server-support-rest

cas-server-support-jdbc

cas-server-webapp

c3p0 可选

mysql-connector-java

cas-management-webapp 这个暂时还没弄懂


2、web.xml

添加的filter:

一是CorsFilter:解决WEB端与CAS端跨域问题


    <filter>        <filter-name>CorsFilter</filter-name>        <filter-class>org.apache.catalina.filters.CorsFilter</filter-class>    </filter>    <filter-mapping>        <filter-name>CorsFilter</filter-name>        <url-pattern>/*</url-pattern>    </filter-mapping>


3、\src\main\webapp\WEB-INF\spring-configuration\propertyFileConfigurer.xml

WINDOWS系统需要把cas.properties和log4j2.xml手动拷贝到WEB服务器上,把路径加入到下边的location中。linux中是/etc/cas/cas.properties


<util:properties id="casProperties" location="file:D:\apache-tomcat-8.0.28\webapps\etc\cas\cas.properties" /><context:property-placeholder properties-ref="casProperties" />

4、把一下三个SAML相关的文件删除,因为我们不用安全断言标记语言

src\main\webapp\WEB-INF下的cas-servlet-saml.xml

src\main\webapp\WEB-INF\spring-configuration\argumentExtractorsConfiguration.xml

src\main\webapp\WEB-INF\spring-configuration\uniqueIdGenerators.xml


5、加入以下两个文件

src\main\webapp\WEB-INF\deployerConfigContext.xml

这里配置JDBC数据源、连接池等,以及注册被保护的服务registeredServicesList


<util:list id="registeredServicesList">    <bean class="org.jasig.cas.services.RegexRegisteredService"         p:id="1"         p:name="HTTPS and IMAPS services on example.com"         p:serviceId="http.*.+"         p:evaluationOrder="0"/></util:list>


src\main\webapp\WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml
其中一个Bean名字是ticketGrantingTicketCookieGenerator,它的属性cookieSecure="false"表示使用http,true表示使用https
<bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"                p:cookieSecure="false"                p:cookieMaxAge="-1"                p:cookieName="TGC"                p:cookiePath="/cas" />
将参数p:cookieSecure="true"改为p:cookieSecure="false",同理为HTTPS验证相关,TRUE为采用HTTPS验证,与deployerConfigContext.xml的参数保持一致。参数p:cookieMaxAge="-1",简单说是COOKIE的最大生命周期,-1为无生命周期,即只在当前打开的IE窗口有效,IE关闭或重新打开其它窗口,仍会要求验证。可以根据需要修改为大于0的数字,比如3600等,意思是在3600秒内,打开任意IE窗口,都不需要验证。

6、把web.xml中的这个删除,因为不用saml
<servlet-mapping>    <servlet-name>cas</servlet-name>    <url-pattern>/samlValidate</url-pattern></servlet-mapping>

7、这样我们的CAS服务已经配置好了,打包,把war包放在tomcat下,启动。


8、此时我们的应用就可以访问CAS服务进行认证了,默认的获取TGT的url是http://ip:8080/cas/v1/tickets

获取ST的url是上个接口返回的,并且带有TGT参数。




0 0
原创粉丝点击