Working on a REST API application using Grails 3.3.5 and Spring-security-rest 2.0.0-RC1.
When I log in using /api/login I got correctly this as result:
{
"username": "[email protected]",
"roles": [
"ROLE_USER"
],
"access_token": "qgsbpk05jfrbf33xx08m8r4govkg53d1"
}
I'd like to add other information in the response, like name and surname of the user. Thanks
UPDATE Thanks to Evgeny that points me in the right direction and reading the manual I implement also a UserDetailsService. From the manual:
If you want to render additional information in your JSON response, you have to:
Configure an alternative userDetailsService bean that retrieves the additional information you want, and put it in a principal object. Configure an alternative accessTokenJsonRenderer that reads that information from the restAuthenticationToken.principal object.
You can override accessTokenJsonRenderer bean
class MyRestAuthTokenJsonRenderer implements AccessTokenJsonRenderer { @Override String generateJson(AccessToken accessToken){ // create response, see DefaultAccessTokenJsonRenderer.groovy from https://github.com/alvarosanchez/grails-spring-security-rest return your_formatted_json_response } }
beans = { accessTokenJsonRenderer(MyRestAuthTokenJsonRenderer) }