Repository navigation
feat: add optional SW360KeycloakClient with automatic token renewal - #72
Merged
Merged
Conversation
SW360 is given a finished token and cannot renew it, so operations running longer than the token lifetime fail once it expires. SW360KeycloakClient takes the Keycloak client_id and client_secret instead and renews the token shortly before expiry. SW360 and SW360Keycloak are unchanged, existing callers keep working as before.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to the discussion in sw360/capycli#242 about where token refresh for long running operations should happen. (berke581@5da20c6)
SW360Keycloak(added in #51) can obtain a token, butSW360only accepts a finished token and has no way to renew it. So when a token expires in the middle of a long run, the caller has to handle the refresh itself.This adds an optional
SW360KeycloakClientwhich takesclient_idandclient_secretinstead of a token. It obtains the token, caches it, and requests a new one shortly before expiry — for session requests as well as for methods that readapi_headersdirectly. Unless a session is passed in it creates its own, so the session shared bySW360instances stays untouched.SW360andSW360Keycloakare unchanged, existing callers keep working as before.Known limitation: expiry is taken from the
expclaim, so a token revoked before it expires is not detected.Happy to adjust it or to close this if you'd rather keep the refresh handling on the capycli side.