CAS 4.1.0-SNAPSHOT how to get oAuth attributes (from facebook etc..) using play-pac4j_scala

StackOverflow https://stackoverflow.com//questions/25008852

  •  20-12-2019
  •  | 
  •  

سؤال

I've set applicationContext.xml on my CAS server as in cas-pac4j-oauth-client-demo and deployerConfigContext.xml is configured as following: 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>

On my client app (play-pac4j_scala) user profile is retrieved via getUserProfile(request)

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 after authorization looks like:

 profile : <CasProfile> | id: Google2Profile#106266612345679456931 | attributes: {} | roles: [] | permissions: [] | isRemembered: false | 

How to get name and email attributes from CAS?

PS. https://mycasserver.net/serviceValidate response contains only cas:user,

tried also such service configuration:

    <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>

versions: CAS 4.1.0-SNAPSHOT, play-pac4j_scala 1.3.0-SNAPSHOT, pac4j-cas 1.6.0-SNAPSHOT, pac4j-oauth 1.6.0-SNAPSHOT

هل كانت مفيدة؟

المحلول

User's attributes can be pushed using SAML validation or the new /p3/serviceValidate endpoint which is not handled yet by any official release of the CAS client on which pac4j is based.. Should be for the next one...

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top