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

Created on 8 May 2019  路  20Comments  路  Source: jhipster/generator-jhipster

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)
[email protected] D:\tmp\check-zuul\gw
`-- [email protected]

##### **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(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 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)
[email protected] D:\tmp\check-zuul\svc
`-- [email protected]

##### **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(TM) SE Runtime Environment (build 1.8.0_202-b08)
Java HotSpot(TM) 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

  • [x] 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

$$ bug-bounty $$ $100 area OIDOAuth2 microservice

All 20 comments

You mentioned "Microsoft". Are you using Microsoft as your OIDC provider? If so, does the same behavior happen with Keycloak?

No that is typo, not microsoft, I mean microservice.
OIDC that I use keycloak 6.0.1.

Hmmm, it sounds like Spring Security might not be fetching refresh tokens and renewing access tokens for you. I'm not sure how to fix just yet.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pascalgrimaud picture pascalgrimaud  路  4Comments

edvjacek picture edvjacek  路  3Comments

chegola picture chegola  路  4Comments

frantzynicolas picture frantzynicolas  路  3Comments

dronavallisaikrishna picture dronavallisaikrishna  路  3Comments