8000 Add IdP configuration to disable forwarding of the acr_values parameter by knutz3n · Pull Request #39814 · keycloak/keycloak · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add IdP configuration to disable forwarding of the acr_values parameter #39814

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1450,6 +1450,8 @@ byConfiguration=By configuration
usersAdded_other={{count}} users added to the group
userFedUnlinkUsersConfirmTitle=Unlink all users?
passCurrentLocale=Pass current locale
passAcrValues=Pass acr_values
passAcrValuesHelp=Pass the current acr_values query parameter on to the identity provider.
realmNameField=Realm name
roleCreated=Role created
socialProfileJSONFieldPath=Social Profile JSON Field Path
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const ExtendedNonDiscoverySettings = () => {
<SwitchField label="passLoginHint" field="config.loginHint" />
<SwitchField label="passMaxAge" field="config.passMaxAge" />
<SwitchField label="passCurrentLocale" field="config.uiLocales" />
<SwitchField label="passAcrValues" field="config.forwardAcrValues" />
<SwitchField
field="config.backchannelSupported"
label="backchannelLogout"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,11 @@ protected UriBuilder createAuthorizationUrl(AuthenticationRequest request) {
uriBuilder.queryParam(OAuth2Constants.PROMPT, prompt);
}

String acr = request.getAuthenticationSession().getClientNote(OAuth2Constants.ACR_VALUES);
if (acr != null) {
uriBuilder.queryParam(OAuth2Constants.ACR_VALUES, acr);
if (getConfig().isForwardAcrValues()) {
String acr = request.getAuthenticationSession().getClientNote(OAuth2Constants.ACR_VALUES);
if (acr != null) {
uriBuilder.queryParam(OAuth2Constants.ACR_VALUES, acr);
}
}
String forwardParameterConfig = getConfig().getForwardParameters() != null ? getConfig().getForwardParameters(): "";
List<String> forwardParameters = Arrays.asList(forwardParameterConfig.split("\\s*,\\s*"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class OAuth2IdentityProviderConfig extends IdentityProviderModel {
public static final String PKCE_METHOD = "pkceMethod";
public static final String TOKEN_ENDPOINT_URL = "tokenUrl";
public static final String TOKEN_INTROSPECTION_URL = "tokenIntrospectionUrl";
public static final String FORWARD_ACR_VALUES = "forwardAcrValues";

public static final String JWT_X509_HEADERS_ENABLED = "jwtX509HeadersEnabled";

Expand Down Expand Up @@ -143,6 +144,14 @@ public void setForwardParameters(String forwardParameters) {
getConfig().put("forwardParameters", forwardParameters);
}

public boolean isForwardAcrValues() {
return Boolean.parseBoolean(getConfig().getOrDefault(FORWARD_ACR_VALUES, "false"));
}

public void setForwardAcrValues(boolean forwardAcrValues) {
getConfig().put(FORWARD_ACR_VALUES, String.valueOf(forwardAcrValues));
}

public boolean isPkceEnabled() {
return Boolean.parseBoolean(getConfig().getOrDefault(PKCE_ENABLED, "false"));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package org.keycloak.testsuite.broker;

import org.junit.Test;
import org.keycloak.admin.client.resource.IdentityProviderResource;
import org.keycloak.admin.client.resource.UsersResource;
import org.keycloak.representations.idm.IdentityProviderRepresentation;
import org.keycloak.representations.idm.UserRepresentation;
import org.keycloak.testsuite.Assert;

Expand All @@ -18,8 +21,29 @@ protected BrokerConfiguration getBrokerConfiguration() {
return KcOidcBrokerConfiguration.INSTANCE;
}

@Test
public void testLogInAsUserInIDPWithAcrValues() {
// Forward acr_values = true
IdentityProviderResource idpRes = adminClient
.realm(bc.consumerRealmName())
.identityProviders()
.get(BrokerTestConst A9BA ants.IDP_OIDC_ALIAS);
IdentityProviderRepresentation idpRep = idpRes.toRepresentation();
OIDCIdentityProviderConfigRep cfg = new OIDCIdentityProviderConfigRep(idpRep);
cfg.setForwardAcrValues(true);
idpRes.update(idpRep);

assertValidLogin(true);

testSingleLogout();
}

@Override
protected void loginUser() {
assertValidLogin(false);
}

private void assertValidLogin(boolean expectHasAcrValues) {
oauth.clientId("broker-app");
loginPage.open(bc.consumerRealmName());

Expand All @@ -33,8 +57,13 @@ protected void loginUser() {
Assert.assertTrue("Driver should be on the provider realm page right now",
driver.getCurrentUrl().contains("/auth/realms/" + bc.providerRealmName() + "/"));

Assert.assertTrue(ACR_VALUES + "=" + ACR_3 + " should be part of the url",
driver.getCurrentUrl().contains(ACR_VALUES + "=" + ACR_3));
if (expectHasAcrValues) {
Assert.assertTrue(ACR_VALUES + "=" + ACR_3 + " SHOULD be part of the url",
driver.getCurrentUrl().contains(ACR_VALUES + "=" + ACR_3));
} else {
Assert.assertFalse(ACR_VALUES + "=" + ACR_3 + " SHOULD NOT be part of the url",
driver.getCurrentUrl().contains(ACR_VALUES + "=" + ACR_3));
}

log.debug("Logging in");
loginPage.login(bc.getUserLogin(), bc.getUserPassword());
Expand Down
Loading
0