So, I'm building my first project that will be used in production with medium-high traffic.
I've decided to use Keycloak as an IdP for it, NodeJS as a backend, React to frontend (both on TypeScript). For the back-end I want to use a bearer-token as authentication.
As I've been studying about Keycloak, I've seen that it uses JWT tokens filled up with data from the user. I also stumbled across some people that advised AGAINST using JWT tokens with data from the user.
The points that were made seemed pretty valid to me to be honest - but now, what is my alternative to them when using Keycloak? Okay, if I used my own authentication & authorization systems I could just use classic sessions I guess. But I don't know how to implement them in Keycloak. Also, it seems strange to me that somethings as popular and big as Keycloak would use something that would be bad by default (JWT) - so I'm not really sure if I should even change this mechanism.
So, my questions are:
Am I safe to use JWT tokens with user's data? (default for Keycloak) Here's how it looks:
{
exp: 1645637327,
iat: 1645601327,
jti: 'removed',
iss: 'http://localhost:8080/auth/realms/supercatalog',
aud: 'account',
sub: 'removed',
typ: 'Bearer',
azp: 'restapi',
session_state: '2434f33d-73c4-4f38-8c80-e92356380ffa',
acr: '1',
'allowed-origins': [ '' ],
realm_access: {
roles: [
'app-elev',
'offline_access',
'uma_authorization',
'default-roles-supercatalog'
]
},
resource_access: { restapi: { roles: [Array] }, account: { roles: [Array] } },
scope: 'email profile',
sid: 'removed',
email_verified: false,
preferred_username: 'elev'
}
If not, what would be an alternative, while still using Keycloak?