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

[ELY-2284] Wildfly OIDC secured App generates a lot of keycloak requests #1654

Merged
merged 1 commit into from
Jan 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -167,28 +167,37 @@ public String getAuthServerBaseUrl() {

public void setProviderUrl(String providerUrl) {
this.providerUrl = providerUrl;
resetUrls();
}


public void setAuthServerBaseUrl(OidcJsonConfiguration config) {
this.authServerBaseUrl = config.getAuthServerUrl();
if (authServerBaseUrl == null) return;
resetUrls();
}

/**
* Resets all calculated urls to null and sets the relativeUrls field
* depending the value of the current discovery URL in the configuration.
* If it is relative is set to ALWAYS and if absolute is set to NEVER.
*/
protected void resetUrls() {
authUrl = null;
providerUrl = null;
tokenUrl = null;
logoutUrl = null;
accountUrl = null;
registerNodeUrl = null;
unregisterNodeUrl = null;
jwksUrl = null;

URI authServerUri = URI.create(authServerBaseUrl);

if (authServerUri.getHost() == null) {
relativeUrls = RelativeUrlsUsed.ALWAYS;
} else {
// We have absolute URI in config
relativeUrls = RelativeUrlsUsed.NEVER;
relativeUrls = null;
if (providerUrl != null || authServerBaseUrl != null) {
URI uri = URI.create(providerUrl != null? providerUrl : authServerBaseUrl);
if (uri.getHost() == null) {
relativeUrls = RelativeUrlsUsed.ALWAYS;
} else {
// We have absolute URI in config
relativeUrls = RelativeUrlsUsed.NEVER;
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,8 @@ private void performAuthentication(InputStream oidcConfig, String username, Stri
try {
Map<String, Object> props = new HashMap<>();
OidcClientConfiguration oidcClientConfiguration = OidcClientConfigurationBuilder.build(oidcConfig);
assertEquals(OidcClientConfiguration.RelativeUrlsUsed.NEVER, oidcClientConfiguration.getRelativeUrls());

OidcClientContext oidcClientContext = new OidcClientContext(oidcClientConfiguration);
oidcFactory = new OidcMechanismFactory(oidcClientContext);
HttpServerAuthenticationMechanism mechanism = oidcFactory.createAuthenticationMechanism(OIDC_NAME, props, getCallbackHandler());
Expand Down