use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class KeycloakModelUtils method createManagementClient.
public static ClientModel createManagementClient(RealmModel realm, String name) {
ClientModel client = createClient(realm, name);
client.setBearerOnly(true);
return client;
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class MigrateTo8_0_0 method migrateRealmCommon.
protected void migrateRealmCommon(RealmModel realm) {
ClientModel adminConsoleClient = realm.getClientByClientId(Constants.ADMIN_CONSOLE_CLIENT_ID);
if (adminConsoleClient != null) {
adminConsoleClient.setRootUrl(Constants.AUTH_ADMIN_URL_PROP);
String adminConsoleBaseUrl = "/admin/" + realm.getName() + "/console/";
adminConsoleClient.setBaseUrl(adminConsoleBaseUrl);
adminConsoleClient.setRedirectUris(Collections.singleton(adminConsoleBaseUrl + "*"));
adminConsoleClient.setWebOrigins(Collections.singleton("+"));
}
ClientModel accountClient = realm.getClientByClientId(Constants.ACCOUNT_MANAGEMENT_CLIENT_ID);
if (accountClient != null) {
accountClient.setRootUrl(Constants.AUTH_BASE_URL_PROP);
String accountClientBaseUrl = "/realms/" + realm.getName() + "/account/";
accountClient.setBaseUrl(accountClientBaseUrl);
accountClient.setRedirectUris(Collections.singleton(accountClientBaseUrl + "*"));
}
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class MigrationUtils method addAdminRole.
public static void addAdminRole(RealmModel realm, String roleName) {
ClientModel client = realm.getMasterAdminClient();
if (client != null && client.getRole(roleName) == null) {
RoleModel role = client.addRole(roleName);
role.setDescription("${role_" + roleName + "}");
client.getRealm().getRole(AdminRoles.ADMIN).addCompositeRole(role);
}
if (!realm.getName().equals(Config.getAdminRealm())) {
client = realm.getClientByClientId(Constants.REALM_MANAGEMENT_CLIENT_ID);
if (client != null && client.getRole(roleName) == null) {
RoleModel role = client.addRole(roleName);
role.setDescription("${role_" + roleName + "}");
client.getRole(AdminRoles.REALM_ADMIN).addCompositeRole(role);
}
}
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class AuthenticationFlowResolver method resolveDirectGrantFlow.
public static AuthenticationFlowModel resolveDirectGrantFlow(AuthenticationSessionModel authSession) {
AuthenticationFlowModel flow = null;
ClientModel client = authSession.getClient();
String clientFlow = client.getAuthenticationFlowBindingOverride(AuthenticationFlowBindings.DIRECT_GRANT_BINDING);
if (clientFlow != null) {
flow = authSession.getRealm().getAuthenticationFlowById(clientFlow);
if (flow == null) {
throw new ModelException("Client " + client.getClientId() + " has direct grant flow override, but this flow does not exist");
}
return flow;
}
return authSession.getRealm().getDirectGrantFlow();
}
use of org.keycloak.models.ClientModel in project keycloak by keycloak.
the class LogoutEndpoint method authorizeClient.
private ClientModel authorizeClient() {
ClientModel client = AuthorizeClientUtil.authorizeClient(session, event, cors).getClient();
cors.allowedOrigins(session, client);
if (client.isBearerOnly()) {
throw new CorsErrorResponseException(cors, Errors.INVALID_CLIENT, "Bearer-only not allowed", Response.Status.BAD_REQUEST);
}
return client;
}
Aggregations