Search code examples
jwtspring-oauth2

JWT access token public information and size


Right now my Spring OAuth2 JWT access token contains following information:

enter image description here

Is it safe to have authorities in public access in this JWT token ?

Also, the size of this token is 1500 bytes. Is it normal for JWT ? What is the size limitation for JWT tokens ?


Solution

  • I would hide some information from potential attackers, f.e. userId. This helps protect the user from access to personal data.

    F.e. if I have some Facebook user's id, I can get him/her page at the URI http://facebook.com/u/{userId}.

    You can encrypt JWT with the help of JSON Web Encryption or you can use alternate user unique key, that inaccessible through the URI.

    As for the size of a token, there isn't special restrictions. But I think you should decrease the size, if you can because this is a remote call. In your case you can use bits instead of full permission names.