Re: [cas-user] Re: How to get google attributes in PAC4J

2019-03-15 Thread Indika Munaweera
Thank you very much Andy.

I was using CAS 6.0.0-RC4-SNAPSHOT and upgraded to 6.1.0-RC3-SNAPSHOT. I 
really appreciate you taking the time to answer my question.



On Friday, March 15, 2019 at 8:56:24 AM UTC+5:30, Andy Ng wrote:
>
> Hello,
>
> What version of CAS are you in? If you are in CAS > 5.3.9 (or the latest 
> CAS 6.x), since Pac4j is updated to 3.6.1:
>
> You should see that *emails *is no longer there and there is an *email 
> *attribute 
> instead (which is in plain string)
>
> So you can get that very easily, no need to decode handle Google2Email.
>
>
> See if the above helps you
>
> Cheers!
> - Andy
>
>

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/b62f0cb6-34f8-45d3-9b9c-efb170bfdc72%40apereo.org.


Re: [cas-user] Re: How to get google attributes in PAC4J

2019-03-14 Thread Andy Ng
Hello,

What version of CAS are you in? If you are in CAS > 5.3.9 (or the latest 
CAS 6.x), since Pac4j is updated to 3.6.1:

You should see that *emails *is no longer there and there is an *email 
*attribute 
instead (which is in plain string)

So you can get that very easily, no need to decode handle Google2Email.


See if the above helps you

Cheers!
- Andy

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/1a97f300-c54c-4773-adf4-c3fba4571b9c%40apereo.org.


Re: [cas-user] Re: How to get google attributes in PAC4J

2019-03-14 Thread Indika Munaweera
I am having the same issue. 
 [result=Service Access 
Granted,service=http://localhost:/login/cas,principal=SimplePrincipal(id=102313159136078677102,
 
attributes={access_token=[ya29.GlzMBibZB2IIac9qMvpdqQ3ZqOufogMmVCkDFvsSG3-qM88mb_Sa-CgNcK0LLHFxO4TJ_ugz7uiTDFUOW7YTi_PXVgVTmuIGYWSdzt11pPpVoxfc6s66OK1DcTJRvw],
 
displayName=[Indika Munaweera], 
emails=[org.pac4j.oauth.profile.google2.Google2Email@6b8a5964], 
image.url=[https://lh3.googleusercontent.com/-r9n1gDd0euo/AAI/Brw/YFvvFzZ25T4/s50/photo.jpg],
 
language=[en], name.familyName=[Munaweera], 
name.givenName=[Indika]}),requiredAttributes={}]

I need emails=[org.pac4j.oauth.profile.google2.Google2Email@6b8a5964]object 
in JSON format as the other values. 

Any help is highly appreciated. 

Thanks,

On Friday, October 27, 2017 at 1:21:50 AM UTC+5:30, leleuj wrote:
>
> Hi,
>
> It should work. The authentication delegation is handled by the 
> ClientAction or DelegatedClientAuthenticationAction class (the name has 
> changed over versions) which uses the ClientAuthenticationHandler. In this 
> handler, the user profile attributes are used to build the SimplePrincipal: 
> when you turn on the DEBUG logs on org.jasig/org.apereo, what do you see 
> for the built principal?
> Thanks.
> Best regards,
> Jérôme
>
>
> On Thu, Oct 26, 2017 at 6:28 AM, Edward  > wrote:
>
>> Hi All,
>> Thank you very much for your response:
>>
>> 1. my scope for google is:
>> cas.authn.pac4j.google.scope=EMAIL_AND_PROFILE
>>
>> 2. after add logging.level.org.pac4j=DEBUG
>> i can see in the log that google return lot of attributes:
>> 2017-10-26 11:56:34,573 INFO 
>> [org.pac4j.oauth.profile.creator.OAuth20ProfileCreator] - >  "kind": "plus#person",
>>  "etag": "\"xx/x\"",
>>  "emails": [
>>   {
>>"value": "x.x...@gmail.com ",
>>"type": "account"
>>   }
>>  ],
>>  "objectType": "person",
>>  "id": "15125125125125",
>>  "displayName": "xx",
>>  "name": {
>>   "familyName": "X",
>>   "givenName": "Xxx"
>>  },
>>  "url": "https://plus.google.com/15125125125125;,
>>  "image": {
>>   "url": "
>> https://lh4.googleusercontent.com/-XFxyqk/XXX/XXXcv/-XXXasaXX/photo.jpg?sz=50
>> ",
>>   "isDefault": false
>>  },
>>  "isPlusUser": true,
>>  "language": "en_GB",
>>  "circledByCount": 6,
>>  "verified": false
>> }
>> >
>>
>> but the final user profile JSON string i got is still the same, not the 
>> full one like above.
>> {
>>   "attributes":
>>   {
>> "clientName": "Google"
>>   },
>>   "id": "15125125125125"
>> }
>>
>>
>> 3. this is how i get CAS user profile :
>> HttpClient client = new HttpClient();
>> tring profileUrl = "
>> https://mydomain.dom.com:8443/cas/oauth2.0/profile?access_token=AT-5-BXWqunDZXTVBZT6jSC6bjqfqodO7JStxJUf
>> ";
>> GetMethod method = new GetMethod(profileUrl);
>> client.executeMethod(method);
>> resultStr = method.getResponseBodyAsString();
>> //*resultStr* only contain above JSON string.
>>
>> 4. in the service configuration:
>> {
>>   @class: org.apereo.cas.support.oauth.services.OAuthRegisteredService
>>   serviceId: ^https://mydomain.dom.com:8443/cas-users-management/.*
>>   name: CAS User Management
>>   id: 1506918968305
>>   description: CAS user management
>>   proxyPolicy:
>>   {
>> @class: org.apereo.cas.services.RefuseRegisteredServiceProxyPolicy
>>   }
>>   evaluationOrder: 0
>>   usernameAttributeProvider:
>>   {
>> @class: 
>> org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider
>> canonicalizationMode: NONE
>> encryptUsername: false
>>   }
>>   attributeReleasePolicy:
>>   {
>> @class: org.apereo.cas.services.*ReturnAllAttributeReleasePolicy*
>> principalAttributesRepository:
>> {
>>   @class: 
>> org.apereo.cas.authentication.principal.DefaultPrincipalAttributesRepository
>>   expiration: 2
>>   timeUnit: HOURS
>> }
>> authorizedToReleaseCredentialPassword: false
>> authorizedToReleaseProxyGrantingTicket: false
>> excludeDefaultAttributes: false
>>   }
>>
>> ..
>>
>> i still cannot get the additional attributes from google. 
>> Any suggestion? 
>>
>> Thanks!
>>
>>>
>>> -- 
>> - Website: https://apereo.github.io/cas
>> - Gitter Chatroom: https://gitter.im/apereo/cas
>> - List Guidelines: https://goo.gl/1VRrw7
>> - Contributions: https://goo.gl/mh7qDG
>> --- 
>> You received this message because you are subscribed to the Google Groups 
>> "CAS Community" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to cas-user+u...@apereo.org .
>> To view this discussion on the web visit 
>> https://groups.google.com/a/apereo.org/d/msgid/cas-user/6c9869dc-f7d4-42d7-9aba-c846d2fb810c%40apereo.org
>>  
>> 
>> .
>>
>
>

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: 

[cas-user] Re: How to get google attributes in PAC4J

2017-10-25 Thread Edward
Hi All,
Thank you very much for your response:

1. my scope for google is:
cas.authn.pac4j.google.scope=EMAIL_AND_PROFILE

2. after add logging.level.org.pac4j=DEBUG
i can see in the log that google return lot of attributes:
2017-10-26 11:56:34,573 INFO 
[org.pac4j.oauth.profile.creator.OAuth20ProfileCreator] - https://plus.google.com/15125125125125;,
 "image": {
  "url": 
"https://lh4.googleusercontent.com/-XFxyqk/XXX/XXXcv/-XXXasaXX/photo.jpg?sz=50;,
  "isDefault": false
 },
 "isPlusUser": true,
 "language": "en_GB",
 "circledByCount": 6,
 "verified": false
}
>

but the final user profile JSON string i got is still the same, not the 
full one like above.
{
  "attributes":
  {
"clientName": "Google"
  },
  "id": "15125125125125"
}


3. this is how i get CAS user profile :
HttpClient client = new HttpClient();
tring profileUrl = 
"https://mydomain.dom.com:8443/cas/oauth2.0/profile?access_token=AT-5-BXWqunDZXTVBZT6jSC6bjqfqodO7JStxJUf;;
GetMethod method = new GetMethod(profileUrl);
client.executeMethod(method);
resultStr = method.getResponseBodyAsString();
//*resultStr* only contain above JSON string.

4. in the service configuration:
{
  @class: org.apereo.cas.support.oauth.services.OAuthRegisteredService
  serviceId: ^https://mydomain.dom.com:8443/cas-users-management/.*
  name: CAS User Management
  id: 1506918968305
  description: CAS user management
  proxyPolicy:
  {
@class: org.apereo.cas.services.RefuseRegisteredServiceProxyPolicy
  }
  evaluationOrder: 0
  usernameAttributeProvider:
  {
@class: org.apereo.cas.services.DefaultRegisteredServiceUsernameProvider
canonicalizationMode: NONE
encryptUsername: false
  }
  attributeReleasePolicy:
  {
@class: org.apereo.cas.services.*ReturnAllAttributeReleasePolicy*
principalAttributesRepository:
{
  @class: 
org.apereo.cas.authentication.principal.DefaultPrincipalAttributesRepository
  expiration: 2
  timeUnit: HOURS
}
authorizedToReleaseCredentialPassword: false
authorizedToReleaseProxyGrantingTicket: false
excludeDefaultAttributes: false
  }

..

i still cannot get the additional attributes from google. 
Any suggestion? 

Thanks!

>
>

-- 
- Website: https://apereo.github.io/cas
- Gitter Chatroom: https://gitter.im/apereo/cas
- List Guidelines: https://goo.gl/1VRrw7
- Contributions: https://goo.gl/mh7qDG
--- 
You received this message because you are subscribed to the Google Groups "CAS 
Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to cas-user+unsubscr...@apereo.org.
To view this discussion on the web visit 
https://groups.google.com/a/apereo.org/d/msgid/cas-user/6c9869dc-f7d4-42d7-9aba-c846d2fb810c%40apereo.org.