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

Added ability to set token's lifespan for server mode #150

Merged
merged 2 commits into from
Oct 6, 2023

Conversation

Akvel
Copy link

@Akvel Akvel commented Sep 18, 2023

Hi,

subj

In some cases we need checks refresh/401 in tests. For this case we need configure exp field for server mode.

Here the little changes that add this funtionality.

@Akvel Akvel force-pushed the feature/allow-configure-server-token-exp branch from 323d989 to 8998caf Compare September 18, 2023 14:54
@Akvel Akvel force-pushed the feature/allow-configure-server-token-exp branch from 8998caf to 93213c9 Compare September 18, 2023 14:56
@ostrya
Copy link
Collaborator

ostrya commented Sep 22, 2023

Thanks for the PR. But I wonder: does your use case, i.e. testing if an expired token is rejected, really warrant a server configuration which is applied globally? I would have just added an option to the TokenConfig class to configure the lifespan.

Or do you mean you start the mock as a standalone application? In that case, I'd have added a CLI option to configure the lifespan. Alternatively, you could add another input field to the "login" page.

@Akvel
Copy link
Author

Akvel commented Sep 25, 2023

Thanks for the PR. But I wonder: does your use case, i.e. testing if an expired token is rejected, really warrant a server configuration which is applied globally? I would have just added an option to the TokenConfig class to configure the lifespan.

Or do you mean you start the mock as a standalone application? In that case, I'd have added a CLI option to configure the lifespan. Alternatively, you could add another input field to the "login" page.

Hello,

In my case, KeycloakMock is set up as a server directly in tests, and it is used to process all authorizations. There are cases when I need to verify the correctness of token refreshing via URL and ensure that the new token is used in all parts. For this, I need the ability to specify the token's lifespan in the ServerConfig.

The application uses Spring oauth2 client to work with Keycloak, which automatically refreshes tokens internally. Therefore, I cannot use TokenConfig and getAccessToken.

@ostrya ostrya self-requested a review October 6, 2023 07:16
Signed-off-by: Akvel <[email protected]>

Amended by ostrya <[email protected]>
@ostrya ostrya force-pushed the feature/allow-configure-server-token-exp branch from 5fdfdcc to 7d3d673 Compare October 6, 2023 07:27
@ostrya
Copy link
Collaborator

ostrya commented Oct 6, 2023

I took the liberty of amending your fix commit so the pre-commit hook check is actually green. Otherwise, since your explanation makes sense, let's just go for it.

@ostrya ostrya merged commit b940695 into TNG:main Oct 6, 2023
4 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.

3 participants