Skip to content

Conversation

zeapo
Copy link
Contributor

@zeapo zeapo commented Jul 4, 2025

After the upgrade to Spring Boot 3.5.x, the authorized client manager will attempt a refresh of the oidc id token.

Sadly, I thought that it would be a simple clean replacement of the previous hackish code. However, it looks like vaadin does not like the SpringContextHolder.setContext() hacks (if you guys have a solution I'm all ears). Here's what happens when the token expires:

  • We get to the interceptor, it calls getToken, which detecting that the token expired will call a refresh
  • During the refresh, spring security will try to reload the oidc user, we end up in the OidcUserService bean which is going to try to refresh the user
  • In that exact bean, sadly, we tried to fetch the rights of the user , which in turn will call the interceptor, and we loop again!

Unfortunately, i'm unable to make the SpringContextHolder clear and use the temporary context in this situation, regardless of changing the strategy, the interceptor is always using the previous context.

To remediate this, I went with a bandaid, I fetch the previous user and re-use its grants; this works! But it is not the ideal solution :)

Here's an example of how it works, it refreshes properly:

Screen.Recording.2025-07-07.at.15.40.36.mov

@zeapo zeapo marked this pull request as ready for review July 7, 2025 13:47
@avgustinmm
Copy link
Contributor

@zeapo ,
is this PR finalized? Working, for review and for eventual merge?

@zeapo
Copy link
Contributor Author

zeapo commented Jul 14, 2025

@avgustinmm hey, it's done. I've been testing it for a while on our deployment.

I'm off for the next two weeks, won't be able to test changes on my work environment.

@zeapo
Copy link
Contributor Author

zeapo commented Jul 27, 2025

Please let me know if anything is missing :)

@zeapo zeapo force-pushed the feature/fix-oauth-hack branch from 66938d9 to 5c19021 Compare August 25, 2025 12:04
Copy link


// This ensures that there is a client already, otherwise we won't be able to call the manager for authorization
OAuth2AuthorizedClient authorizedClient = clientService.loadAuthorizedClient(registrationId, authentication.getName());
if (authorizedClient == null) return null;
if (authorizedClient == null) return currentToken;
Copy link
Contributor

Choose a reason for hiding this comment

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

If client isn't found why return a token ?

Copy link
Contributor Author

@zeapo zeapo Sep 1, 2025

Choose a reason for hiding this comment

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

Hehe, this is the tricky parts of how simple-ui rights are working. It hijacks the authentication process, hence the initial step where it fetches the rights to create the authorities, the authorizedClient does not exist.

That's why this OIDC process is much more complex than it should've been.

image Screenshot 2025-09-01 at 14 31 10

Copy link

@desislava-marinova desislava-marinova left a comment

Choose a reason for hiding this comment

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

LGTM

@avgustinmm avgustinmm dismissed their stale review September 5, 2025 08:08

fixed after

@avgustinmm avgustinmm merged commit 4b6b175 into eclipse-hawkbit:master Sep 5, 2025
5 checks passed
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