in Education by
I have a JHipster monolithic app with oauth2 running Keycloak locally. I don't know how exactly should jhipster work with oauth2... first I thought it would create the user automatically, but it didn't, so I configured keycloak: I created the jhipster realm, the web_app client, the client roles ROLE_ADMIN and ROLE_USER, and the users admin and user with their correct roles. The problem is that when I login as admin it is not being recognized as ROLE_ADMIN, as a result I cannot access the administrator menu. So I started looking through the code, trying to understand how Jhipster receives the credentials from Keycloak, and I realized that the OAuth2Authentication object in AccountResource.java does not bring the ROLE_ADMIN, but the ROLE_USER which I don't understand why. The OAuth2Authentication object in json looks like this: { "authorities": [ { "authority": "ROLE_USER" } ], "details": { "remoteAddress": "0:0:0:0:0:0:0:1", "sessionId": "rkkveY_Xa5zFFd0SKu9Of_FLGRnbdiTPHdnpj4gc", "tokenValue": "eyJhbGciOiJSUzI1...", "tokenType": "bearer", "decodedDetails": null }, "authenticated": true, "userAuthentication": { "authorities": [ { "authority": "ROLE_USER" } ], "details": { "sub": "f348bbbb-9441-4543-9940-9da31e50d877", "email _verified": true, "name": "Admin Administrator", "preferred_username": "admin", "given_name": "Admin", "family_name": "Administrator", "email": "admin@localhost" }, "authenticated": true, "principal": "Admin Administrator", "credentials": "N/A", "name": "Admin Administrator" }, "clientO nly": false, "principal": "Admin Administrator", "oauth2Request": { "clientId": "web_app", "scope": [ ], "requestParameters": { }, "resourceIds": [ ], "authorities": [ ], "approved": true, "refresh": false, "redirectUri": null, "responseTypes": [ ], "extensions": { }, "grantType": null, "refreshTok enRequest": null }, "credentials": "", "name": "Admin Administrator" } here is the yo-rc.json: { "generator-jhipster": { "promptValues": { "packageName": "xxxxxxxxxxx" }, "jhipsterVersion": "5.7.2", "applicationType": "monolith", "baseName": "XXXXXXXXXX", "packageName": "xxxxxxxxxxxxxx", "packageFolder": "xxxxxxxxxxxxxx", "serverPort": "8080", "authenticationType": "oauth2", "cacheProvider": "ehcache", "enableHibernateCache": true, "websocket": false, "databaseType": "sql", "devDatabaseType": "h2Disk", "prodDatabaseType": "mysql", "searchEngine": false, "messageBroker": false, "serviceDiscoveryType": false, "buildTool": "maven", "enableSwaggerCodegen": false, "clientFramework": "angularX", "useSass": false, "clientPackageManager": "npm", "testFrameworks": [], "jhiPrefix": "jhi", "otherModules": [], "enableTranslation": false } } How can I fix this? JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
In keycloak administration go to Clients >> YOUR_CLIENT >> Mappers -> Add new mapper -> Set mapper type to "User client Role" and "Token claim name" set to "authorities" and Claim JSON Type to string.

Related questions

0 votes
    When I've registered an object foo to receive KVO notifications from another object bar (using addObserver:. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 24, 2022 in Education by JackTerrance
0 votes
    I have a fairly similar docker-compose file to what is officially provided namely version: '3' volumes: ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Has any else experienced when logging into to sitecore it says too many users are logged but when you ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    Details: We are using Keycloak authentication server with Asp.Net WebAPI. Now I need to get the Keycloak ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 4, 2022 in Education by JackTerrance
0 votes
    I've been working with Symfony (2.x) for the first time and I had some questions regarding the ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 18, 2022 in Education by JackTerrance
0 votes
    I have minified all my js files using require, but require created a minified js file( main.min.js ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 18, 2022 in Education by JackTerrance
0 votes
    I have minified all my js files using require, but require created a minified js file( main.min.js ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 16, 2022 in Education by JackTerrance
0 votes
    I am using MQTT client library from this link https://www.hivemq.com/blog/mqtt-client-library-encyclopedia- ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 9, 2022 in Education by JackTerrance
0 votes
    I have a mobile app(react-native), a resource service(spring boot) and Keycloak Authenticatioin Service(Auth ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 7, 2022 in Education by JackTerrance
0 votes
    Symfony version: 3.1.3 Due to development reason suddenly my app giving the following error and I believe ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 8, 2022 in Education by JackTerrance
0 votes
    When I try to open the Plesk Login Page via :8443 I get the Error: ERROR: Uncaught Error: Class ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 10, 2022 in Education by JackTerrance
0 votes
    Neelam has offered physics, chemistry and mathematics in Class XII. She estimates that her probabilities of receiving a ... A grades. Select the correct answer from above options...
asked Nov 16, 2021 in Education by JackTerrance
0 votes
    Find the receiving impedance of a transmission line having a voltage of 24V and a conduction current ... by,electromagnetic theory engineering physics,electromagnetic theory nptel...
asked Nov 6, 2021 in Education by JackTerrance
...