cas4.1.9单点登录配置

1.连接数据库

1.修改WEB-INF目录下deployerConfigContext.xml

注释掉<!--     <bean id="primaryAuthenticationHandler" -->
<!--           class="org.jasig.cas.authentication.AcceptUsersAuthenticationHandler"> -->
<!--         <property name="users"> -->
<!--             <map> -->
<!--                 <entry key="casuser" value="Mellon"/> -->
<!--             </map> -->
<!--         </property> -->
<!--     </bean> -->

添加下面的代码

 <!-- 设置密码的加密方式,这里使用的是MD5加密 -->
    <bean id="passwordEncoder"
      class="org.jasig.cas.authentication.handler.DefaultPasswordEncoder"
      c:encodingAlgorithm="MD5"
      p:characterEncoding="UTF-8" />

    <!-- 通过数据库验证身份1 -->
    <bean id="primaryAuthenticationHandler"
      class="com.XX.cas.QueryDatabaseAuthenticationHandler"
      p:dataSource-ref="dataSource"
      p:passwordEncoder-ref="passwordEncoder"
      p:sql="select user_password from s_user where binary user_name=? and is_disenable = '0'" />
     
  <!-- 设置数据源1 -->
     <bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
          <property name="driverClassName" value="com.mysql.jdbc.Driver"></property>
          <property name="url" value="jdbc:mysql://localhost:3306/faceform?useUnicode=true&amp;characterEncoding=utf8"></property>
          <property name="username" value="ceshi"></property>
          <property name="password" value="ceshi"></property>  
    </bean>

com.XX.cas.QueryDatabaseAuthenticationHandler为自定义的验证方法

sql语句添加binary是为了区分密码大小写

3.修改cas支持http协议

(1)、修改WEB-INF\deployerConfigContext.xml,加入p:requireSecure="false"  

 <bean id="proxyAuthenticationHandler"
 class="org.jasig.cas.authentication.handler.support.HttpBasedServiceCredentialsAuthenticationHandler"
          p:httpClient-ref="supportsTrustStoreSslSocketFactoryHttpClient"
           p:requireSecure= "false"/>

(2)、修改WEB-INF\spring-configuration\ticketGrantingTicketCookieGenerator.xml,修改p:cookieSecure="false"

 <bean id="ticketGrantingTicketCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
          c:casCookieValueManager-ref="cookieValueManager"
          p:cookieSecure="false"
          p:cookieMaxAge="-1"
          p:cookieName="TGC"
          p:cookiePath=""/>

(3)、修改修改WEB-INF\spring-configuration\warnCookieGenerator.xml,修改p:cookieSecure="false"

<bean id="warnCookieGenerator" class="org.jasig.cas.web.support.CookieRetrievingCookieGenerator"
          p:cookieHttpOnly="true"
          p:cookieSecure="false"
          p:cookieMaxAge="-1"
          p:cookieName="CASPRIVACY"
          p:cookiePath=""/>

(4)、修改HTTPSandIMAPS-10000001.json文件,

{
  "@class" : "org.jasig.cas.services.RegexRegisteredService",
  "serviceId" : "^(https|imaps|http)://.*",
  "name" : "HTTPS and IMAPS",
  "id" : 10000001,
  "description" : "This service definition authorized all application urls that support HTTPS and IMAPS protocols.",
  "proxyPolicy" : {
    "@class" : "org.jasig.cas.services.RefuseRegisteredServiceProxyPolicy"
  },

 

补充问题:

子系统用户登录的时候把用户信息保存到了session里面,在多个子系统整合的时候发现通过IP和端口号以及url地址访问另外一个项目的时候,无法获取到session信息。

解决办法:通过域名加端口号进行访问,而且子系统需要在同一个一级域名下

转载于:https://my.oschina.net/keke412/blog/780533

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值