jasig CAS 实现单点登录 - java、php客户端登录实现

 jasig CAS项目本身就是一个完整的CAS单点登录服务

1、服务端需要把  认证处理类、用户属性返回值处理类 调整成我们自己处理类即可实现单点登录

2、java客户端需要引入cas-client-core客户端jar包,添加所需的过滤器即可(如果原项目具有验证登录的过滤器/拦截器,需要根据具体需要进行小调整)

3、部署到linux服务器,登录成功后跳转异常

[http-nio-21300-exec-4] ERROR org.apache.catalina.core.ContainerBase.[Tomcat].[localhost].[/].[dispatcherServlet] - Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [org.jasig.cas.client.validation.TicketValidationException: No principal was found in the response from the CAS server.] with root cause
org.jasig.cas.client.validation.TicketValidationException: No principal was found in the response from the CAS server............

[http-nio-21300-exec-4] ERROR org.jasig.cas.client.util.XmlUtils - 元素类型 "meta" 必须由匹配的结束标记 "</meta>" 终止。
org.xml.sax.SAXParseException: 元素类型 "meta" 必须由匹配的结束标记 "</meta>" 终止。..............
找了好久,本地没有此异常,服务器异常定位不清晰,最后才想到web服务器要调用CAS服务器验证ticket,忘了配置host。

CAS4.0 参考文献:

http://www.cnblogs.com/vhua/p/cas_1.html

http://blog.csdn.net/frinder/article/details/7969925 

 

PHP客户端:

http://blog.csdn.net/fei1502816/article/details/6695117

http://www.bubuko.com/infodetail-1145996.html 

http://blog.csdn.net/haiqiao_2010/article/details/38365733 

让其他文件支持php代码:

http://laoxiege.blog.sohu.com/116742025.html 

php单点退出方式:phpCAS::handleLogoutRequests(mode, casHost, casIp));

1、mode是ip是否外网解析,值为true或false

2、casHost是cas服务器的域名,casIp是cas服务器的ip。如果不加这两个参数,当handleLogoutRequests校验登出请求时就会失败,也就使得应用不能登出了。

3、如果退出拦截成功会自动清除session数据

百般折磨尝试后的成功示例:phpCAS::handleLogoutRequests(false,'login.mr-world.com',"117.78.35.137");

php端非常奇怪的问题:跳转登录多出参数gateway=true导致无限循环来回跳转,无法正确跳转登录页
使用nginx服务器有问题,使用apache服务器没问题
验证登录页与登录成功回跳页一样的情况下也会出现一次gateway=true

posted @ 2016-07-20 09:33  べ袽猓柯苡づ  阅读(4345)  评论(4编辑  收藏  举报