Skip to content
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

Fixes to refresh tokens. #15508

Merged
merged 4 commits into from
Jun 30, 2021
Merged

Fixes to refresh tokens. #15508

merged 4 commits into from
Jun 30, 2021

Conversation

mshima
Copy link
Member

@mshima mshima commented Jun 30, 2021


Please make sure the below checklist is followed for Pull Requests.

When you are still working on the PR, consider converting it to Draft (bellow reviewers) and adding skip-ci label, you can still see CI build result at your branch.

@mshima
Copy link
Member Author

mshima commented Jun 30, 2021

@mraible I couldn't get to work reactive to redirect to oauth2 login url.

.authorizationCode()
.refreshToken(builder -> builder.clockSkew(Duration.ofMinutes(1)))
.clientCredentials()
.password()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks strange. Why do we need a password here and where does it come from?

@bdemers Can you have a look at this? We're trying to get refresh tokens working in JHipster.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -46,6 +46,7 @@ public class OAuth2ReactiveRefreshTokensWebFilter implements WebFilter {
.filter(principal -> principal instanceof OAuth2AuthenticationToken)
.cast(OAuth2AuthenticationToken.class)
.flatMap(authentication -> authorizedClient(exchange, authentication))
.onErrorResume(e -> Mono.empty())
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It should redirect to the oauth2 login here.
If the token is expired, an error is returned.

@mshima
Copy link
Member Author

mshima commented Jun 30, 2021

Merging.
It fixes a problem with expired tokens, where the session get stuck in a broken state.
The refresh token still works correctly.

Reverts the old behavior of expired tokens for reactive and redirect to oauth2 login for non-reactive.

discussion can continue.

@mshima mshima merged commit 9d12776 into jhipster:main Jun 30, 2021
@mshima mshima deleted the skip_ci-oauth2_refresh branch June 30, 2021 12:28
}

@Override
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws IOException, ServletException {
public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain)
throws IOException, ServletException {
Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
if ((authentication instanceof OAuth2AuthenticationToken)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can remove the doubled parenthesis

@pascalgrimaud pascalgrimaud added this to the 7.2.0 milestone Jul 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants