8000 [Admin API v2] Skeleton prototype by mabartos · Pull Request #39322 · 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,225 @@
package org.keycloak.representations.admin.v2;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonPropertyDescription;

import java.util.Set;

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public class ClientRepresentation {

@JsonProperty(required = true)
@JsonPropertyDescription("ID uniquely identifying this client")
private String clientId;

@JsonPropertyDescription("Human readable name of the client")
private String displayName;

@JsonPropertyDescription("Human readable description of the client")
private String description;

@JsonPropertyDescription("The protocol used to communicate with the client")
private String protocol;

@JsonPropertyDescription("Whether this client is enabled")
private Boolean enabled;

@JsonPropertyDescription("URL to the application's homepage that is represented by this client")
private String appUrl;

@JsonPropertyDescription("URLs that the browser can redirect to after login")
private Set<String> appRedirectUrls;

@JsonPropertyDescription("Login flows that are enabled for this client")
private Set<String> loginFlows;

@JsonPropertyDescription("Authentication configuration for this client")
private Auth auth;

@JsonPropertyDescription("Web origins that are allowed to make requests to this client")
private Set<String> webOrigins;

@JsonPropertyDescription("Roles associated with this client")
private Set<String> roles;

@JsonPropertyDescription("Service account configuration for this client")
private ServiceAccount serviceAccount;

public ClientRepresentation() {}

public ClientRepresentation(String clientId) {
this.clientId = clientId;
}

public String getClientId() {
return clientId;
}

public void setClientId(String clientId) {
this.clientId = clientId;
}

public String getDisplayName() {
return displayName;
}

public void setDisplayName(String displayName) {
this.displayName = displayName;
}

public String getDescription() {
return description;
}

public void setDescription(String description) {
this.description = description;
}

public String getProtocol() {
return protocol;
}

public void setProtocol(String protocol) {
this.protocol = protocol;
}

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public String getAppUrl() {
return appUrl;
}

public void setAppUrl(String appUrl) {
this.appUrl = appUrl;
}

public Set<String> getAppRedirectUrls() {
return appRedirectUrls;
}

public void setAppRedirectUrls(Set<String> appRedirectUrls) {
this.appRedirectUrls = appRedirectUrls;
}

public Set<String> getLoginFlows() {
return loginFlows;
}

public void setLoginFlows(Set<String> loginFlows) {
this.loginFlows = loginFlows;
}

public Auth getAuth() {
return auth;
}

public void setAuth(Auth auth) {
this.auth = auth;
}

public Set<String> getWebOrigins() {
return webOrigins;
}

public void setWebOrigins(Set<String> webOrigins) {
this.webOrigins = webOrigins;
}

public Set<String> getRoles() {
return roles;
}

public void setRoles(Set<String> roles) {
this.roles = roles;
}

public ServiceAccount getServiceAccount() {
return serviceAccount;
}

public void setServiceAccount(ServiceAccount serviceAccount) {
this.serviceAccount = serviceAccount;
}

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class Auth {

@JsonPropertyDescription("Whether authentication is enabled for this client")
private Boolean enabled;

@JsonPropertyDescription("Which authentication method is used for this client")
private String method;

@JsonPropertyDescription("Secret used to authenticate this client with Secret authentication")
private String secret;

@JsonPropertyDescription("Public key used to authenticate this client with Signed JWT authentication")
private String certificate;

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public String getMethod() {
return method;
}

public void setMethod(String method) {
this.method = method;
}

public String getSecret() {
return secret;
}

public void setSecret(String secret) {
this.secret = secret;
}

public String getCertificate() {
return certificate;
}

public void setCertificate(String certificate) {
this.certificate = certificate;
}
}

@JsonInclude(JsonInclude.Include.NON_EMPTY)
public static class ServiceAccount {

@JsonPropertyDescription("Whether the service account is enabled")
private Boolean enabled;

@JsonPropertyDescription("Roles assigned to the service account")
private Set<String> roles;

public Boolean getEnabled() {
return enabled;
}

public void setEnabled(Boolean enabled) {
this.enabled = enabled;
}

public Set<String> getRoles() {
return roles;
}

public void setRoles(Set<String> roles) {
this.roles = roles;
}
}
}

12 changes: 12 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@
<!-- Used to test SAML Galleon feature-pack layers discovery -->
<version.org.wildfly.glow>1.0.0.Alpha8</version.org.wildfly.glow>

<org.mapstruct.version>1.6.3</org.mapstruct.version>

<!-- Galleon -->
<galleon.fork.embedded>true</galleon.fork.embedded>
<galleon.log.time>true</galleon.log.time>
Expand Down Expand Up @@ -388,6 +390,11 @@
<artifactId>xsom</artifactId>
<version>${org.glassfish.jaxb.xsom.version}</version>
</dependency>
<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
<version>${org.mapstruct.version}</version>
</dependency>
Comment on lines +393 to +397
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure about productization but I assume it's build time only processor.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I've checked, it is fully productized.


<dependency>
<groupId>org.bouncycastle</groupId>
Expand Down Expand Up @@ -1107,6 +1114,11 @@
<artifactId>keycloak-admin-ui</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-rest-admin-ui-ext</artifactId>
Expand Down
16 changes: 16 additions & 0 deletions quarkus/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@
<artifactId>rdf-urdna</artifactId>
</dependency>

<dependency>
<groupId>org.mapstruct</groupId>
<artifactId>mapstruct</artifactId>
</dependency>

<!-- SmallRye -->
<dependency>
<groupId>io.smallrye.config</groupId>
Expand Down Expand Up @@ -390,6 +395,17 @@
</exclusions>
</dependency>

<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-api</artifactId>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- Keycloak Dependencies-->
<dependency>
<groupId>org.jboss.logging</groupId>
Expand Down
4 changes: 4 additions & 0 deletions quarkus/tests/junit5/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
<groupId>org.infinispan</groupId>
<artifactId>infinispan-server-testdriver-core</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-api</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down
40 changes: 40 additions & 0 deletions rest/admin-api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
< 10BC8 ?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-rest-parent</artifactId>
<version>999.0.0-SNAPSHOT</version>
</parent>

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

<properties>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-core</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-server-spi</artifactId>
</dependency>
<dependency>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jakarta.ws.rs-api</artifactId>
</dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-services</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.keycloak.admin.api;

import jakarta.ws.rs.Path;
import org.keycloak.admin.api.realm.RealmsApi;
import org.keycloak.provider.Provider;

public interface AdminApi extends Provider {

@Path("realms")
RealmsApi realms();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package org.keycloak.admin.api;

import jakarta.ws.rs.OPTIONS;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.core.Context;
import org.eclipse.microprofile.openapi.annotations.Operation;
import org.keycloak.models.KeycloakSession;
import org.keycloak.services.resources.admin.AdminCorsPreflightService;

@jakarta.ws.rs.ext.Provider
@Path("admin/api")
public class AdminRootV2 {
Comment thread
mabartos marked this conversation as resolved.
Resolved

@Context
protected KeycloakSession session;

@Path("")
public AdminApi latestAdminApi() {
// we could return the latest Admin API if no version is specified
return new DefaultAdminApi(session);
}

@Path("v2")
public AdminApi adminApi() {
return new DefaultAdminApi(session);
}

@Path("{any:.*}")
@OPTIONS
@Operation(hidden = true)
public Object preFlight() {
return new AdminCorsPreflightService();
}
}
Loading
0