use of org.keycloak.models.ClientScopeModel in project keycloak by keycloak.
the class SamlProtocolFactory method createDefaultClientScopesImpl.
@Override
protected void createDefaultClientScopesImpl(RealmModel newRealm) {
ClientScopeModel roleListScope = newRealm.addClientScope(SCOPE_ROLE_LIST);
roleListScope.setDescription("SAML role list");
roleListScope.setDisplayOnConsentScreen(true);
roleListScope.setConsentScreenText(ROLE_LIST_CONSENT_TEXT);
roleListScope.setProtocol(getId());
roleListScope.addProtocolMapper(builtins.get("role list"));
newRealm.addDefaultClientScope(roleListScope, true);
}
use of org.keycloak.models.ClientScopeModel in project keycloak by keycloak.
the class UPConfigUtils method validateScopes.
private static void validateScopes(Set<String> scopes, String propertyName, String attributeName, List<String> errors, KeycloakSession session) {
if (scopes == null) {
return;
}
for (String scope : scopes) {
RealmModel realm = session.getContext().getRealm();
Stream<ClientScopeModel> realmScopes = realm.getClientScopesStream();
if (!realmScopes.anyMatch(cs -> cs.getName().equals(scope))) {
errors.add(new StringBuilder("'").append(propertyName).append("' configuration for attribute '").append(attributeName).append("' contains unsupported scope '").append(scope).append("'").toString());
}
}
}
use of org.keycloak.models.ClientScopeModel in project keycloak by keycloak.
the class HardcodedClientStorageProvider method getClientScopes.
@Override
public Map<String, ClientScopeModel> getClientScopes(RealmModel realm, ClientModel client, boolean defaultScope) {
if (defaultScope) {
ClientScopeModel rolesScope = KeycloakModelUtils.getClientScopeByName(realm, OIDCLoginProtocolFactory.ROLES_SCOPE);
ClientScopeModel webOriginsScope = KeycloakModelUtils.getClientScopeByName(realm, OIDCLoginProtocolFactory.WEB_ORIGINS_SCOPE);
return Arrays.asList(rolesScope, webOriginsScope).stream().collect(Collectors.toMap(ClientScopeModel::getName, clientScope -> clientScope));
} else {
ClientScopeModel offlineScope = KeycloakModelUtils.getClientScopeByName(realm, "offline_access");
return Collections.singletonMap("offline_access", offlineScope);
}
}
Aggregations