generator-jhipster icon indicating copy to clipboard operation
generator-jhipster copied to clipboard

Enrich user information results in NullPointerException if "preferred_username" is not existing

Open lazyo666 opened this issue 3 years ago • 1 comments

Overview of the issue

Every call to the Gateway results in a NullPointerException if claim do not contain the "preferred_username".

java.lang.NullPointerException: Cannot invoke "Object.toString()" because the return value of "java.util.Map.get(Object)" is null

Motivation for or Use Case

Successfully call a route of the gateway

Reproduce the error
  1. Genrate a gateway project
  2. Call [gateway]/api/gateway/routes
Related issues
Suggest a Fix

https://github.com/jhipster/generator-jhipster/blob/main/generators/server/templates/src/main/java/package/config/SecurityConfiguration_reactive.java.ejs#L444

JHipster Version(s)

JHipster 7.9.2

JHipster configuration

{ "generator-jhipster": { "applicationType": "gateway", "authenticationType": "oauth2", "baseName": "gateway", "blueprints": [], "buildTool": "maven", "cacheProvider": "no", "clientFramework": "no", "clientPackageManager": "npm", "clientTheme": "none", "clientThemeVariant": "", "creationTimestamp": 1634563324703, "databaseType": "no", "devDatabaseType": "no", "devServerPort": 9060, "dtoSuffix": "DTO", "enableGradleEnterprise": false, "enableHibernateCache": false, "enableSwaggerCodegen": false, "enableTranslation": false, "entities": [], "entitySuffix": "", "jhiPrefix": "jhi", "jhipsterVersion": "7.9.2", "jwtSecretKey": "YourJWTSecretKeyWasReplacedByThisMeaninglessTextByTheJHipsterInfoCommandForObviousSecurityReasons", "languages": ["en", "fr"], "messageBroker": false, "nativeLanguage": "de", "otherModules": [], "packageName": "com.mycompany.myapp", "pages": [], "prodDatabaseType": "no", "reactive": true, "searchEngine": false, "serverPort": "8080", "serverSideOptions": [], "serviceDiscoveryType": "consul", "skipCheckLengthOfIdentifier": false, "skipClient": true, "skipFakeData": false, "skipServer": false, "skipUserManagement": true, "testFrameworks": [], "websocket": false, "withAdminUi": true } }

  • [x] Checking this box is mandatory (this is just to show you read everything)

lazyo666 avatar Aug 04 '22 15:08 lazyo666

@lazyo666 What identity provider do you experience this with? I haven't seen it with Keycloak, Okta, or Auth0. Nevertheless, it's a worthwhile check. Can you please provide a PR?

mraible avatar Aug 09 '22 21:08 mraible

I'll close this soon if no identity provider is provided.

mraible avatar Aug 15 '22 00:08 mraible

Closing due to lack of response.

mraible avatar Aug 17 '22 08:08 mraible