File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -15,15 +15,15 @@ const fs = require('fs');
1515 let token = await keycloak . jwt . verify ( someAccessToken )
1616 console . log ( token . isExpired ( ) )
1717 console . log ( token . hasRealmRole ( 'user' ) )
18- console . log ( token . hasApplicationRole ( 'nodejs-connect ' , 'vlm-readonly ' ) )
18+ console . log ( token . hasApplicationRole ( 'my-application ' , 'my-role ' ) )
1919
2020 // verify token offline, intended for micro-service authorization
2121 // using this method does not consider token invalidation, avoid long-term tokens here
2222 const cert = fs . readFileSync ( './local/public_cert.pem' )
2323 token = await keycloak . jwt . verifyOffline ( someAccessToken , cert )
2424 console . log ( token . isExpired ( ) )
2525 // console.log(token.hasRealmRole('user'))
26- // console.log(token.hasApplicationRole('nodejs-connect ', 'vlm-readonly '))
26+ // console.log(token.hasApplicationRole('my-application ', 'my-role '))
2727
2828 // how to manually refresh custom access token
2929 // (this operation is performed automatically for the service access token)
Original file line number Diff line number Diff line change @@ -6,5 +6,6 @@ keycloak.accessToken.get().then(async (accessToken) => {
66 const token = keycloak . jwt . decode ( accessToken )
77 console . log ( { expired : token . isExpired ( ) } )
88 console . log ( { content : token . content } )
9- console . log ( { hasRole : token . hasApplicationRole ( 'client-name' , 'ROLE_NAME' ) } )
9+ console . log ( { hasRole : token . hasRealmRole ( 'my-role' ) } )
10+ console . log ( { hasRole : token . hasApplicationRole ( 'my-application' , 'my-role' ) } )
1011} )
You can’t perform that action at this time.
0 commit comments