jiyeon爱的小龙虾
2019-09-04 11:43
采纳率: 100%
浏览 2.0k
已采纳

cas5.3.x配置返回多属性问题(java客户端无法获取服务器返回的自定义信息)

问题如题:

其中参照了

https://www.jianshu.com/p/54646ac96473
https://blog.csdn.net/yelllowcong/article/details/79238335

并根据教程做了如下配置:
1、修改service文件,HTTPSandIMAPS-10000001.json

{
  "@class" : "org.apereo.cas.services.RegexRegisteredService",
  "serviceId" : "^(http|https|imaps)://.*",
  "name" : "HTTPS and IMAPS",
  "id" : 10000001,
  "description" : "This service definition authorizes all application urls that support HTTPS and IMAPS protocols.",
  "evaluationOrder" : 10000,
  "attributeReleasePolicy" : {
    "@class" : "org.apereo.cas.services.ReturnAllAttributeReleasePolicy"
  }
}

2、自定义验证以及返回更多的个人信息

3、spring.factories文件配上自己自定义的流程,其他的去掉

org.springframework.boot.autoconfigure.EnableAutoConfiguration=com.gxzytech.config.CustomAuthenticationConfiguration

4、查看后台服务器,确实返回了新加的信息
图片说明

最后问题是,java客户端还是只返回了用户名

图片说明

登录时控制台打印的日志如下,一开始attributes是有值的,后面不知怎么又变空了?难道是这个原因?

2019-09-04 14:46:52,558 INFO [org.apereo.inspektr.audit.support.Slf4jLoggingAuditTrailManager] - <Audit trail record BEGIN
=============================================================
WHO: audit:unknown
WHAT: [result=Service Access Granted,service=http://localhost:8282/node2/,principal=SimplePrincipal(id=admin, attributes={mobil_no=12345678111, email=123456@126, username=admin}),requiredAttributes={}]
ACTION: SERVICE_ACCESS_ENFORCEMENT_TRIGGERED
APPLICATION: CAS
WHEN: Wed Sep 04 14:46:52 CST 2019
CLIENT IP ADDRESS: 0:0:0:0:0:0:0:1
SERVER IP ADDRESS: 0:0:0:0:0:0:0:1
2019-09-04 14:46:52,569 INFO [org.apereo.cas.DefaultCentralAuthenticationService] - <Granted ticket [ST-5-GCMpvMiMoVABKskshh9TqrsSNUUlkk-PC] for service [http://localhost:8282/node2/] and principal [admin]>
2019-09-04 14:46:52,569 INFO [org.apereo.inspektr.audit.support.Slf4jLoggingAuditTrailManager] - <Audit trail record BEGIN
=============================================================
WHO: admin
WHAT: ST-5-GCMpvMiMoVABKskshh9TqrsSNUUlkk-PC for http://localhost:8282/node2/
ACTION: SERVICE_TICKET_CREATED
APPLICATION: CAS
WHEN: Wed Sep 04 14:46:52 CST 2019
CLIENT IP ADDRESS: 0:0:0:0:0:0:0:1
SERVER IP ADDRESS: 0:0:0:0:0:0:0:1
=============================================================

>
2019-09-04 14:46:52,684 INFO [org.apereo.inspektr.audit.support.Slf4jLoggingAuditTrailManager] - <Audit trail record BEGIN
=============================================================
WHO: audit:unknown
WHAT: [result=Service Access Granted,service=http://localhost:8282/node2/,principal=SimplePrincipal(id=admin, attributes={}),requiredAttributes={}]
ACTION: SERVICE_ACCESS_ENFORCEMENT_TRIGGERED
APPLICATION: CAS
WHEN: Wed Sep 04 14:46:52 CST 2019
CLIENT IP ADDRESS: 127.0.0.1
SERVER IP ADDRESS: 127.0.0.1
=============================================================
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • jiyeon爱的小龙虾 2019-09-06 16:17
    已采纳

    解决了。。。配置问题!
    主要是当时配置了HTTPSandIMAPS-10000001.json的返回策略Return All(所有配置返回的都返回) ,但是没有配置landingone-1000.json的返回策略, 所以后面意识到后加上了返回策略属性后,成功获取到对应的个人信息了图片说明

    后记:当时我怀疑是不是cas服务器session没有存有返回的个人信息。。都已经查询cas服务端&客户端源码了。。

    小结:还是得熟悉常见的文件,搭建的步骤。

    已采纳该答案
    评论
    解决 1 无用
    打赏 举报

相关推荐 更多相似问题