generator-jhipster: Access to microservice from gateway failed after 5 minute idle, re authentication required

Overview of the issue

When the user is idle for more than 5 minutes, access from the browser to microservice is not authenticated.

Motivation for or Use Case

After 5 minute idle, access to the entire menu in the gateway, no need for authentication, only related to the microservice that needs authentication. For public users, it will be a bit confusing.

Reproduce the error
  1. Create a gateway application with security oauth2.
  2. Create a microservice application with security oauth2.
  3. Create one entity with the description field on microservice.
  4. run “jhipster entity Data1” from the command prompt
  5. Copy entity to gateway, do same thing with command “jhipster entity Data1 --skip-server”
  6. Run gateway and microservice, open Data-1 from entities->Data 1
**Gateway Configuration **

jhipster info INFO! Using JHipster version installed locally in current project’s node_modules INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
gateway@0.0.0 D:\tmp\check-zuul\gw
`-- generator-jhipster@6.0.0

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany"
    },
    "jhipsterVersion": "6.0.0",
    "applicationType": "gateway",
    "baseName": "gateway",
    "packageName": "com.mycompany",
    "packageFolder": "com/mycompany",
    "serverPort": "8080",
    "authenticationType": "oauth2",
    "cacheProvider": "ehcache",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "clientFramework": "angularX",
    "clientTheme": "none",
    "clientThemeVariant": "",
    "useSass": true,
    "clientPackageManager": "npm",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Data1 {
  description String
}
dto Data1 with mapstruct
paginate Data1 with pagination
service Data1 with serviceClass
microservice Data1 with svc
clientRootFolder Data1 with svc

Environment and Tools

java version “1.8.0_202” Java™ SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot™ 64-Bit Server VM (build 25.202-b08, mixed mode)

git version 2.19.1.windows.1

node: v10.15.3

npm: 6.9.0

yeoman: 2.0.6

yarn: 1.9.4

Docker version 18.09.2, build 6247962

docker-compose version 1.23.2, build 1110ad01

**Microservice Configuration **

jhipster info INFO! Using JHipster version installed locally in current project’s node_modules INFO! Executing jhipster:info INFO! Options: from-cli: true Welcome to the JHipster Information Sub-Generator

JHipster Version(s)
svc@0.0.0 D:\tmp\check-zuul\svc
`-- generator-jhipster@6.0.0

JHipster configuration, a .yo-rc.json file generated in the root folder
.yo-rc.json file
{
  "generator-jhipster": {
    "promptValues": {
      "packageName": "com.mycompany"
    },
    "jhipsterVersion": "6.0.0",
    "applicationType": "microservice",
    "baseName": "svc",
    "packageName": "com.mycompany",
    "packageFolder": "com/mycompany",
    "serverPort": "8082",
    "authenticationType": "oauth2",
    "cacheProvider": "hazelcast",
    "enableHibernateCache": false,
    "websocket": false,
    "databaseType": "sql",
    "devDatabaseType": "h2Disk",
    "prodDatabaseType": "mysql",
    "searchEngine": false,
    "messageBroker": false,
    "serviceDiscoveryType": "eureka",
    "buildTool": "maven",
    "enableSwaggerCodegen": false,
    "jwtSecretKey": "bXktc2VjcmV0LXRva2VuLXRvLWNoYW5nZS1pbi1wcm9kdWN0aW9uLWFuZC10by1rZWVwLWluLWEtc2VjdXJlLXBsYWNl",
    "testFrameworks": [],
    "jhiPrefix": "jhi",
    "entitySuffix": "",
    "dtoSuffix": "DTO",
    "otherModules": [],
    "enableTranslation": false,
    "clientPackageManager": "npm",
    "skipClient": true,
    "skipUserManagement": true
  }
}
JDL for the Entity configuration(s) entityName.json files generated in the .jhipster directory
JDL entity definitions
entity Data1 {
  description String
}
dto Data1 with mapstruct
paginate Data1 with pagination
service Data1 with serviceClass
microservice Data1 with svc
clientRootFolder Data1 with svc

Environment and Tools

java version “1.8.0_202” Java™ SE Runtime Environment (build 1.8.0_202-b08) Java HotSpot™ 64-Bit Server VM (build 25.202-b08, mixed mode)

git version 2.19.1.windows.1

node: v10.15.3

npm: 6.9.0

yeoman: 2.0.6

yarn: 1.9.4

Docker version 18.09.2, build 6247962

docker-compose version 1.23.2, build 1110ad01

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

First Open Page:

image

After 5 Minute, and click edit in Form: image

image

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 3
  • Comments: 20 (14 by maintainers)

Most upvoted comments

I’ve been able to reproduce this problem with Spring Boot and Spring Security. The fix suggested doesn’t work. I’ll consult with my colleagues and try to figure out a solution.

Same behavior here: no refresh token fetched from Keycloak (part of the OAuth2AuthenticationToken)