-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Access to microservice from gateway failed after 5 minute idle, re authentication required #9707
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. |
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. |
Same behavior here: no refresh token fetched from Keycloak (part of the OAuth2AuthenticationToken) |
Let me historize what I'm doing within my current project to have a 6.0.0 oauth2+Microservice support.
Change
Side stuff: Update the GrantedAuthorityMapper to handle Keycloak mappings:
|
Could be related to this issue: spring-attic/spring-security-oauth2-boot#125 |
The solution to overcome this problem, as follows.
@EnableWebSecurity
} |
@EnableOAuth2Sso is deprecated in Spring Security 5.1 in favor of oauth2Login() as part of the configure() method. Does it work if you remove that annotation?
… On May 16, 2019, at 12:06, Edy Apriansyah ***@***.***> wrote:
@EnableOAuth2Sso
|
Yes it works, with additional bean: @bean
|
Alternatively, act as client refer from this https://docs.spring.io/spring-security-oauth2-boot/docs/current-SNAPSHOT/reference/htmlsingle/ @EnableOAuth2Client @bean |
If it’s not too much trouble, can you please create a pull request with this change? I’d be happy to review it.
https://github.com/jhipster/generator-jhipster/blob/master/CONTRIBUTING.md#submitting-a-pull-request
I’ll also add $100 bounty to this issue.
… On May 16, 2019, at 13:10, Edy Apriansyah ***@***.***> wrote:
Alternatively, act as client refer from this https://docs.spring.io/spring-security-oauth2-boot/docs/current-SNAPSHOT/reference/htmlsingle/
@EnableOAuth2Client
and add bean:
@bean
@ConfigurationProperties("spring.security.oauth2.client")
public ClientCredentialsResourceDetails oauth2RemoteResource() {
return new ClientCredentialsResourceDetails();
}
@bean
public OAuth2RestTemplate oauth2RestTemplate(OAuth2ClientContext oauth2ClientContext,
OAuth2ProtectedResourceDetails details) {
return new OAuth2RestTemplate(details, oauth2ClientContext);
}
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Just added the bounty @mraible |
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. |
Sorry, I made a mistake. My test folder is mixed with jhipster v5, in the microservice. So the problem is still there. Sorry for this misunderstanding. |
So the bug is in Spring Security 5.1 rather than jhipster? |
I think it's in JHipster. I believe this might be caused by a change I made in AuthorizationHeaderUtil: In the Spring Security 5.0 version, we used an |
From @jzheaux of the Spring Security team:
|
the |
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
**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)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
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)
JHipster configuration, a
.yo-rc.json
file generated in the root folder.yo-rc.json file
JDL for the Entity configuration(s)
entityName.json
files generated in the.jhipster
directoryJDL entity definitions
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
First Open Page:
After 5 Minute, and click edit in Form:

The text was updated successfully, but these errors were encountered: