8000 fix: creating a cleaner module for use by java clients by shawkins · Pull Request #47874 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
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.
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
@@ -0,0 +1,65 @@
/*
* Copyright 2023 Red Hat, Inc. and/or its affiliates
* and other contributors as indicated by the @author tags.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.keycloak.common.constants;

/**
* Class of constants relating to the OpenAPI annotations in Keycloak and the Keycloak Admin REST API
*/
public class KeycloakOpenAPI {

protected KeycloakOpenAPI() { }
public static class Profiles {

public static final String ADMIN = "x-smallrye-profile-admin";

private Profiles() { }
}

public static class Admin {

private Admin() { }

public static class Tags {
public static final String ATTACK_DETECTION = "Attack Detection";
public static final String AUTHENTICATION_MANAGEMENT = "Authentication Management";
public static final String CLIENTS = "Clients";
public static final String CLIENTS_V2 = "Clients (v2)";
public static final String CLIENT_ATTRIBUTE_CERTIFICATE = "Client Attribute Certificate";
public static final String CLIENT_INITIAL_ACCESS = "Client Initial Access";
public static final String CLIENT_REGISTRATION_POLICY = "Client Registration Policy";
public static final String CLIENT_ROLE_MAPPINGS = "Client Role Mappings";
public static final String CLIENT_SCOPES = "Client Scopes";
public static final String COMPONENT = "Component";
public static final String GROUPS = "Groups";
public static final String IDENTITY_PROVIDERS = "Identity Providers";
public static final String KEY = "Key";
public static final String PROTOCOL_MAPPERS = "Protocol Mappers";
public static final String REALMS_ADMIN = "Realms Admin";
public static final String ROLES = "Roles";
public static final String ROLES_BY_ID = "Roles (by ID)";
public static final String ROLE_MAPPER = "Role Mapper";
public static final String ROOT = "Root";
public static final String SCOPE_MAPPINGS = "Scope Mappings";
public static final String USERS = "Users";
public static final String ORGANIZATIONS = "Organizations";
public static final String WORKFLOWS = "Workflows";
private Tags() { }
}

}
}
2 changes: 1 addition & 1 deletion distribution/api-docs-dist/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@
</dependencySourceIncludes>
<dependencySourceExcludes>
<dependencySourceExclude>org.keycloak:keycloak-operator</dependencySourceExclude>
<dependencySourceExclude>org.keycloak:keycloak-admin-v2-rest</dependencySourceExclude>
<dependencySourceExclude>org.keycloak:keycloak-admin-v2-api</dependencySourceExclude>
</dependencySourceExcludes>
</configuration>
<executions>
Expand Down
2 changes: 1 addition & 1 deletion integration/admin-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-rest</artifactId>
<artifactId>keycloak-admin-v2-api</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand Down
3 changes: 1 addition & 2 deletions integration/client-cli/admin-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
<!-- required during compilation by the exec-maven-plugin as we need the OpenAPI document stored in the resources -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-rest</artifactId>
<version>${project.version}</version>
<artifactId>keycloak-admin-v2-services</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
2 changes: 1 addition & 1 deletion js/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
<!-- Enforce build order: openapi.yaml must be generated before JS build -->
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-rest</artifactId>
<artifactId>keycloak-admin-v2-services</artifactId>
<scope>provided</scope>
<exclusions>
<exclusion>
Expand Down
4 changes: 0 additions & 4 deletions operator/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,6 @@
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-api</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-rest</artifactId>
</dependency>

<!-- Test -->
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1121,7 +1121,7 @@
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-rest</artifactId>
<artifactId>keycloak-admin-v2-services</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
Expand Down
2 changes: 1 addition & 1 deletion quarkus/runtime/pom.xml
8 10BC8
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-v2-rest</artifactId>
<artifactId>keycloak-admin-v2-services</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import java.util.List;

import org.keycloak.quarkus.runtime.configuration.mappers.PropertyMappers;

import picocli.CommandLine;

/**
Expand All @@ -38,9 +36,6 @@ public KcUnmatchedArgumentException(CommandLine.UnmatchedArgumentException ex) {

@Override
public List<String> getSuggestions() {
// filter out disabled mappers
return super.getSuggestions().stream()
.filter(f -> PropertyMappers.getKcKeyFromCliKey(f).filter(PropertyMappers::isDisabledMapper).isEmpty())
.toList();
return super.getSuggestions();
}
}
49 changes: 13 additions & 36 deletions rest/admin-v2/api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</parent>

<artifactId>keycloak-admin-v2-api</artifactId>
<name>Keycloak Admin API v2 Interfaces</name>
<name>Keycloak Admin API v2 APIs</name>

<properties>
<maven.compiler.source>17</maven.compiler.source>
Expand All @@ -22,52 +22,29 @@
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi</artifactId>
<scope>provided</scope>
<artifactId>keycloak-common</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi-private</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<groupId>jakarta.validation</groupId>
<artifactId>jakarta.validation-api</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<artifactId>jackson-annotations</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
<groupId>org.eclipse.microprofile.openapi</groupId>
<artifactId>microprofile-openapi-api</artifactId>
</dependency>
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<groupId>org.hibernate.validator</groupId>
<artifactId>hibernate-validator</artifactId>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgument>
-AgeneratedTranslationFilesPath=${project.build.directory}/generated-translation-files
</compilerArgument>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.keycloak.services;
package org.keycloak.admin.api;

public class PatchTypeNames {
public static final String JSON_MERGE = "application/merge-patch+json";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.keycloak.admin.api.PatchTypeNames;
import org.keycloak.representations.admin.v2.BaseClientRepresentation;
import org.keycloak.services.PatchTypeNames;

import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;

import org.keycloak.common.constants.KeycloakOpenAPI;
import org.keycloak.representations.admin.v2.BaseClientRepresentation;
import org.keycloak.services.resources.KeycloakOpenAPI;

import org.eclipse.microprofile.openapi.annotations.Operation;
import org.eclipse.microprofile.openapi.annotations.enums.SchemaType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

import jakarta.validation.constraints.NotBlank;

import org.keycloak.representations.admin.v2.validation.ClientUuidProvider;
import org.keycloak.representations.admin.v2.validation.PatchClient;
import org.keycloak.representations.admin.v2.validation.ProtocolUnmodified;
import org.keycloak.representations.admin.v2.validation.PutClient;
Expand All @@ -30,7 +29,7 @@
@JsonSubTypes.Type(value = OIDCClientRepresentation.class, name = OIDCClientRepresentation.PROTOCOL),
@JsonSubTypes.Type(value = SAMLClientRepresentation.class, name = SAMLClientRepresentation.PROTOCOL)
})
@UuidUnmodified(uuidProvider = ClientUuidProvider.class, groups = {PutClient.class, PatchClient.class})
@UuidUnmodified(groups = {PutClient.class, PatchClient.class})
@ProtocolUnmodified(groups = {PutClient.class, PatchClient.class})
@ValidRedirectUris
public abstract class BaseClientRepresentation extends BaseRepresentation implements RepresentationWithUuid {
Expand Down Expand Up @@ -141,7 +140,9 @@ void setProtocol(String protocol) {

@Override
public boolean equals(Object o) {
if (!(o instanceof BaseClientRepresentation that)) return false;
if (!(o instanceof BaseClientRepresentation that)) {
return false;
}
return Objects.equals(uuid, that.uuid) && Objects.equals(clientId, that.clientId) && Objects.equals(displayName, that.displayName) && Objects.equals(description, that.description) && Objects.equals(enabled, that.enabled) && Objects.equals(appUrl, that.appUrl) && Objects.equals(redirectUris, that.redirectUris) && Objects.equals(roles, that.roles);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
* Validation constraint that requires the {@link OIDCClientRepresentation.Auth#getSecret()} is not blank
* when {@link OIDCClientRepresentation.Auth#getMethod()} is the (JWT) client secret.
*
* @see ClientSecretNotBlankValidator#isClientSecret(String)
*/
@Target(TYPE)
@Retention(RUNTIME)
@Constraint(validatedBy = ClientSecretNotBlankValidator.class)
@Constraint(validatedBy = {})
public @interface ClientSecretNotBlank {

String message() default "Client secret must not be blank";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {ProtocolUnmodifiedValidator.class})
@Documented
@Constraint(validatedBy = {})
public @interface ProtocolUnmodified {
String message() default "protocol cannot be changed for an existing client";
Class<?>[] groups() default {};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {UuidUnmodifiedValidator.class})
@Documented
@Constraint(validatedBy = {})
public @interface UuidUnmodified {
String message() default "UUID is server-managed and must not be user-specified";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
Class<? extends UuidProvider> uuidProvider();
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
*/
@Target({ElementType.TYPE})
@Retention(RetentionPolicy.RUNTIME)
@Constraint(validatedBy = {ValidRedirectUrisValidator.class})
@Constraint(validatedBy = {})
@Documented
public @interface ValidRedirectUris {
String message() default "Invalid redirect URI";
Expand Down
2 changes: 1 addition & 1 deletion rest/admin-v2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
<packaging>pom</packaging>

<modules>
<module>rest</module>
<module>api</module>
<module>services</module>
<module>tests</module>
</modules>
</project>
Loading
Loading
0