1

In Grails, as per this document (http://alvarosanchez.github.io/grails-spring-security-rest/latest/docs/#_token_generation_), in section 9.12, the JWT looks like

          Listing 10. JWT claims
           {
             "exp": 1422990129,
             "sub": "jimi",
              "roles": [
              "ROLE_ADMIN",
               "ROLE_USER"
           ],
           "iat": 1422986529
           } 

How do I add/retrieve additional parameters into this JWT, for example have

      "device_id": 8797079079909  

included in the claims so that, I can hash it. Based on device id, I want to implement a logic that blacklists refresh of tokens

Thanks UK

uk1974
  • 107
  • 1
  • 7
  • The answer here works: [https://stackoverflow.com/questions/49715689/grails-rest-security-add-user-id-to-token](https://stackoverflow.com/questions/49715689/grails-rest-security-add-user-id-to-token) I tested this in Grails `3.3.8` adding my own custom field – A.W. Sep 23 '18 at 05:39

1 Answers1

0

in the same documentation: http://alvarosanchez.github.io/grails-spring-security-rest/next/docs/index.html

At the item:

11.1. Disabling bearer tokens support for full response customisation

It shows how to do it:

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.

It's placed in the wrong place, I believe.

Hope this is what your're looking for, good luck