我在CAS服务器上设置了applicationContext.xml,就像在cas-pac4j-oauth-client-demo中一样 和deployerConfigContext.xml配置如下:complete deployerConfigContext
...
<util:map id="attrRepoBackingMap">
<!-- facebook -->
<entry key="uid" value="uid" />
<entry key="email" value="email" />
<entry key="first_name" value="first_name" />
<entry key="last_name" value="last_name" />
<entry key="username" value="username" />
<!-- google -->
<entry key="verified_email" value="verified_email" />
<entry key="name" value="name" />
<entry key="given_name" value="given_name" />
<entry key="family_name" value="family_name" />
</util:map>
...
<util:list id="registeredServicesList">
<bean class="org.jasig.cas.services.RegexRegisteredService"
p:id="1" p:name="example.com" p:description="Allow example.com connection"
p:serviceId="^http://example.com/.*" p:evaluationOrder="1" >
<property name="attributeReleasePolicy">
<bean class="org.jasig.cas.services.ReturnAllowedAttributeReleasePolicy">
<property name="allowedAttributes">
<list>
<!-- facebook -->
<value>uid</value>
<value>email</value>
<value>first_name</value>
<value>last_name</value>
<value>username</value>
<!-- google -->
<value>verified_email</value>
<value>name</value>
<value>given_name</value>
<value>family_name</value>
</list>
</property>
</bean>
</property>
</bean>
</util:list>
在我的客户端应用程序(play-pac4j_scala)上,通过getUserProfile(请求)检索用户配置文件
def authorization = Action { implicit request =>
val session = getOrCreateSessionId(request)
val casUrl=requestSession2CasUrl(request,session)
val commonProfile = getUserProfile(request)
Ok(views.html.authorization(commonProfile, casUrl)).withSession(session)
}
授权后的commonProfile如下:
profile : <CasProfile> | id: Google2Profile#106266612345679456931 | attributes: {} | roles: [] | permissions: [] | isRemembered: false |
如何从CAS获取姓名和电子邮件属性?
PS。 https://mycasserver.net/serviceValidate响应仅包含cas:user,
也试过这样的服务配置:
<bean class="org.jasig.cas.services.RegexRegisteredService"
p:id="5" p:name="http.all" p:description="Allow HTTP connection"
p:serviceId="^http://.*" p:evaluationOrder="5" >
<property name="attributeReleasePolicy">
<bean class="org.jasig.cas.services.ReturnAllAttributeReleasePolicy" />
</property>
</bean>
版本:CAS 4.1.0-SNAPSHOT,play-pac4j_scala 1.3.0-SNAPSHOT,pac4j-cas 1.6.0-SNAPSHOT,pac4j-oauth 1.6.0-SNAPSHOT
答案 0 :(得分:2)
可以使用SAML验证或新的/ p3 / serviceValidate端点来推送用户的属性,而这个端点尚未由pac4j所基于的CAS客户端的任何官方版本处理..应该是下一个......