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

Bugfix/66602 keycloak access token is not refreshing properly #286

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

MGRLMIS
Copy link
Collaborator

@MGRLMIS MGRLMIS commented Nov 4, 2024

No description provided.

@T-Thurow T-Thurow self-requested a review November 6, 2024 10:23
String? token = await _authProvider.getAccessToken();
if (token == null) {
await _authProvider.refreshAccessToken();
token = await _authProvider.getAccessToken();
Copy link

Choose a reason for hiding this comment

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

This kinda works.
Every first request after the token expires still contains the outdated token and fails.
I think it might be because it reads the new token with getAccessToken right after refreshAccessToken. refreshAccessToken writes the token into the storageService but unawaited so there might be a race condition where the old token is read from storage while the write operation of the new token has not finished?

);

@override
Future<http.StreamedResponse> send(http.BaseRequest request) async {
Copy link

Choose a reason for hiding this comment

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

Overwriting the send method seems a bit to broad to me. It works but it would leak the token to other web endpoints the webui interacts with since the Authorization header will always be set. The usage of the Authorization header should be restricted to the web endpoints that require the header and we trust.

@sply88
Copy link
Collaborator

sply88 commented Nov 20, 2024

Will this still be addressed before the demonstrations?

@MGRLMIS
Copy link
Collaborator Author

MGRLMIS commented Nov 20, 2024

Will this still be addressed before the demonstrations?

I am working on other stories regarding Pontus-X currently. As soon as I'm done with that, I'll take care of this.

Otherwise I am very happy about any support. Be it through concrete suggestions on how to implement it better. I admit my solution is rather "quick and dirty" due to the time constraints we face regarding the deadline.

…systeme/AW40-hub-docker into bugfix/66602_keycloak_access_token_is_not_refreshing_properly
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.

3 participants