Looking at the source code, it seems like the default behavior is to put
attributes on the attributes parameters, and can't change by settings for
now
*OAuth20UserProfileControllerController.java* (line:158 )
protected Map<String, Object> writeOutProfileResponse(final AccessToken
accessToken) throws IOException {
final Principal principal =
accessToken.getAuthentication().getPrincipal();
LOGGER.debug("Preparing user profile response based on CAS
principal [{}]", principal);
final Map<String, Object> map = new HashMap<>();
map.put(ID, principal.getId());
map.put(ATTRIBUTES, principal.getAttributes());
return map;
}
I am not familar with Grafana, so I don't know making code edit in Grafana
is harder or making code edit in CAS is harder, but if you think editing
code in CAS is better, then this is a good read for
you: https://apereo.github.io/2017/02/02/cas51-authn-handlers/
Basically, I will create my own config, then but this into the config:
@Bean
public OAuth20UserProfileControllerController profileController() {
return new
MyOwnOAuth20UserProfileControllerController(servicesManager,
ticketRegistry, oAuthValidator(),
defaultAccessTokenFactory(),
oauthPrincipalFactory(), webApplicationServiceFactory,
profileScopeToAttributesFilter(), casProperties,
ticketGrantingTicketCookieGenerator);
}
Then, edit writeOutProfileResponse in another newly created class
MyOwnOAuth20UserProfileControllerController
Then you can change profile parameter layout as you please.
Hope this helps you!
-Andy
On Friday, 15 September 2017 18:09:19 UTC+8, Peter Smith wrote:
>
> Hi All,
>
> I have managed to get CAS 5.1.3 up and running. I am successfully
> authenticating with Active Directory. Now trying to get Oauth working with
> Grafana. It's working up to the point where Grafana queries
> /cas/oauth2.0/profile
> for the profile.
>
> The error in Grafana: Error getting user info: json: cannot unmarshal
> string into Go struct field .attributes of type []string
>
> A google search has lead me to
> https://github.com/grafana/grafana/issues/8600 that suggests that the
> json structure is different to what Grafana is expecting. According to the
> last post on the page user profile needs to return "name" and "email"
> fields directly, not nested inside attributes object.
>
> So my question now is can I change the structure so that its reported the
> way grafana is expecting? If I can change it any ideas how?
>
>
> Kind regards,
>
> Peter
>
--
- 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 [email protected].
To view this discussion on the web visit
https://groups.google.com/a/apereo.org/d/msgid/cas-user/cc750230-64ff-4cb0-900e-f6cce7b12632%40apereo.org.