mirror of
https://github.com/keycloak/keycloak.git
synced 2026-01-10 15:32:05 -03:30
Add openid scope in Allowed Client Scopes options of client registration access policies
Closes #42339 Signed-off-by: cgeorgilakis-grnet <cgeorgilakis@admin.grnet.gr> Co-authored-by: cgeorgilakis-grnet <cgeorgilakis@admin.grnet.gr>
This commit is contained in:
parent
6a202146b4
commit
b6cee86e74
@ -22,6 +22,7 @@ import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.keycloak.OAuth2Constants;
|
||||
import org.keycloak.component.ComponentModel;
|
||||
import org.keycloak.component.ComponentValidationException;
|
||||
import org.keycloak.models.ClientScopeModel;
|
||||
@ -88,7 +89,12 @@ public class ClientScopesClientRegistrationPolicyFactory extends AbstractClientR
|
||||
if (realm == null) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
return realm.getClientScopesStream().map(ClientScopeModel::getName).collect(Collectors.toList());
|
||||
List<String> scopes = realm.getClientScopesStream().map(ClientScopeModel::getName).collect(Collectors.toList());
|
||||
//add openid scope if not exists
|
||||
if (!scopes.contains(OAuth2Constants.SCOPE_OPENID)) {
|
||||
scopes.add(OAuth2Constants.SCOPE_OPENID);
|
||||
}
|
||||
return scopes;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -383,6 +383,7 @@ public class ClientRegistrationPoliciesTest extends AbstractClientRegistrationTe
|
||||
List<String> clientScopes = getProviderConfigProperty(clientScopeRep, ClientScopesClientRegistrationPolicyFactory.ALLOWED_CLIENT_SCOPES);
|
||||
Assert.assertFalse(clientScopes.isEmpty());
|
||||
Assert.assertTrue(clientScopes.contains(OAuth2Constants.SCOPE_PROFILE));
|
||||
Assert.assertTrue(clientScopes.contains(OAuth2Constants.SCOPE_OPENID));
|
||||
Assert.assertFalse(clientScopes.contains("foo"));
|
||||
Assert.assertFalse(clientScopes.contains("bar"));
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user