KEYCLOAK-18512: Integrate New Admin Console into Keycloak build (#8366)

* KEYCLOAK-18512: Integrate New Admin Console into Keycloak build

* KEYCLOAK-18512: Integrate New Admin Console into Keycloak build

* Change version to project version.  Make experimental.

* Add PAT for reading packages (#12)

* Add PAT for reading packages

* Encode token

* Use generic GH account for installation of packages

* Enable Github packages repo only for snapshots

* KEYCLOAK-18512: Make ADMIN2 experimental instead of preview

* KEYCLOAK-18512: Remove early return

* KEYCLOAK-18512: Fix formatting issue

Co-authored-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Stan Silvert 2021-09-15 10:09:06 -04:00 committed by GitHub
parent 24811f1ef5
commit 93e229e45d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 78 additions and 17 deletions

View file

@ -52,6 +52,7 @@ public class Profile {
ACCOUNT2(Type.DEFAULT), ACCOUNT2(Type.DEFAULT),
ACCOUNT_API(Type.DEFAULT), ACCOUNT_API(Type.DEFAULT),
ADMIN_FINE_GRAINED_AUTHZ(Type.PREVIEW), ADMIN_FINE_GRAINED_AUTHZ(Type.PREVIEW),
ADMIN2(Type.EXPERIMENTAL),
DOCKER(Type.DISABLED_BY_DEFAULT), DOCKER(Type.DISABLED_BY_DEFAULT),
IMPERSONATION(Type.DEFAULT), IMPERSONATION(Type.DEFAULT),
OPENSHIFT_INTEGRATION(Type.PREVIEW), OPENSHIFT_INTEGRATION(Type.PREVIEW),

View file

@ -21,8 +21,7 @@ public class ProfileTest {
@Test @Test
public void checkDefaultsKeycloak() { public void checkDefaultsKeycloak() {
Assert.assertEquals("community", Profile.getName()); Assert.assertEquals("community", Profile.getName());
assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.ADMIN2, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.MAP_STORAGE, Profile.Feature.DECLARATIVE_USER_PROFILE);
assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.MAP_STORAGE, Profile.Feature.DECLARATIVE_USER_PROFILE);
assertEquals(Profile.getPreviewFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.DECLARATIVE_USER_PROFILE); assertEquals(Profile.getPreviewFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.DECLARATIVE_USER_PROFILE);
assertEquals(Profile.getDeprecatedFeatures(), Profile.Feature.UPLOAD_SCRIPTS); assertEquals(Profile.getDeprecatedFeatures(), Profile.Feature.UPLOAD_SCRIPTS);
@ -38,8 +37,7 @@ public class ProfileTest {
Profile.init(); Profile.init();
Assert.assertEquals("product", Profile.getName()); Assert.assertEquals("product", Profile.getName());
assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.ADMIN2, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.WEB_AUTHN, Profile.Feature.MAP_STORAGE, Profile.Feature.DECLARATIVE_USER_PROFILE);
assertEquals(Profile.getDisabledFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.DOCKER, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.UPLOAD_SCRIPTS, Profile.Feature.WEB_AUTHN, Profile.Feature.MAP_STORAGE, Profile.Feature.DECLARATIVE_USER_PROFILE);
assertEquals(Profile.getPreviewFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.WEB_AUTHN, Profile.Feature.DECLARATIVE_USER_PROFILE); assertEquals(Profile.getPreviewFeatures(), Profile.Feature.ADMIN_FINE_GRAINED_AUTHZ, Profile.Feature.SCRIPTS, Profile.Feature.TOKEN_EXCHANGE, Profile.Feature.OPENSHIFT_INTEGRATION, Profile.Feature.WEB_AUTHN, Profile.Feature.DECLARATIVE_USER_PROFILE);
assertEquals(Profile.getDeprecatedFeatures(), Profile.Feature.UPLOAD_SCRIPTS); assertEquals(Profile.getDeprecatedFeatures(), Profile.Feature.UPLOAD_SCRIPTS);

View file

@ -1342,6 +1342,11 @@
<artifactId>keycloak-quarkus-server-app</artifactId> <artifactId>keycloak-quarkus-server-app</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-ui</artifactId>
<version>${project.version}</version>
</dependency>
<!-- Openshift --> <!-- Openshift -->
<dependency> <dependency>

View file

@ -341,6 +341,7 @@ public class AdminConsole {
map.put("resourceCommonUrl", Urls.themeRoot(adminBaseUri).getPath() + "/common/keycloak"); map.put("resourceCommonUrl", Urls.themeRoot(adminBaseUri).getPath() + "/common/keycloak");
map.put("masterRealm", Config.getAdminRealm()); map.put("masterRealm", Config.getAdminRealm());
map.put("resourceVersion", Version.RESOURCES_VERSION); map.put("resourceVersion", Version.RESOURCES_VERSION);
map.put("loginRealm", realm.getName());
map.put("properties", theme.getProperties()); map.put("properties", theme.getProperties());
FreeMarkerUtil freeMarkerUtil = new FreeMarkerUtil(); FreeMarkerUtil freeMarkerUtil = new FreeMarkerUtil();

View file

@ -167,14 +167,9 @@ public class ServerInfoAdminResource {
info.setThemes(new HashMap<>()); info.setThemes(new HashMap<>());
for (Theme.Type type : Theme.Type.values()) { for (Theme.Type type : Theme.Type.values()) {
List<String> themeNames = new LinkedList<>(session.theme().nameSet(type)); List<String> themeNames = filterThemes(type, new LinkedList<>(session.theme().nameSet(type)));
Collections.sort(themeNames); Collections.sort(themeNames);
if (!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) {
themeNames.remove("keycloak.v2");
themeNames.remove("rh-sso.v2");
}
List<ThemeInfoRepresentation> themes = new LinkedList<>(); List<ThemeInfoRepresentation> themes = new LinkedList<>();
info.getThemes().put(type.toString().toLowerCase(), themes); info.getThemes().put(type.toString().toLowerCase(), themes);
@ -197,6 +192,22 @@ public class ServerInfoAdminResource {
} }
} }
private LinkedList<String> filterThemes(Theme.Type type, LinkedList<String> themeNames) {
LinkedList<String> filteredNames = new LinkedList<>(themeNames);
boolean filterAccountV2 = (type == Theme.Type.ACCOUNT) &&
!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2);
boolean filterAdminV2 = (type == Theme.Type.ADMIN) &&
!Profile.isFeatureEnabled(Profile.Feature.ADMIN2);
if (filterAccountV2 || filterAdminV2) {
filteredNames.remove("keycloak.v2");
filteredNames.remove("rh-sso.v2");
}
return filteredNames;
}
private void setSocialProviders(ServerInfoRepresentation info) { private void setSocialProviders(ServerInfoRepresentation info) {
info.setSocialProviders(new LinkedList<>()); info.setSocialProviders(new LinkedList<>());
Stream<ProviderFactory> providerFactories = session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class); Stream<ProviderFactory> providerFactories = session.getKeycloakSessionFactory().getProviderFactoriesStream(SocialIdentityProvider.class);

View file

@ -1,6 +1,5 @@
<?xml version="1.0"?> <?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" <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/maven-v4_0_0.xsd">
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<parent> <parent>
<artifactId>keycloak-parent</artifactId> <artifactId>keycloak-parent</artifactId>
<groupId>org.keycloak</groupId> <groupId>org.keycloak</groupId>
@ -10,7 +9,7 @@
<artifactId>keycloak-themes</artifactId> <artifactId>keycloak-themes</artifactId>
<name>Keycloak Themes</name> <name>Keycloak Themes</name>
<description/> <description />
<packaging>jar</packaging> <packaging>jar</packaging>
<properties> <properties>
@ -19,6 +18,20 @@
<args.npm.install>ci --no-optional --ignore-scripts</args.npm.install> <args.npm.install>ci --no-optional --ignore-scripts</args.npm.install>
</properties> </properties>
<repositories>
<repository>
<id>github</id>
<url>https://keycloak-packages:&#103;hp_tSeU74eZVGTSupVCap28N8TX0M88YJ06kua9@maven.pkg.github.com/keycloak/keycloak-admin-ui</url>
<releases>
<enabled>false</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
<updatePolicy>always</updatePolicy>
</snapshots>
</repository>
</repositories>
<build> <build>
<plugins> <plugins>
<plugin> <plugin>
@ -140,12 +153,44 @@
<name>!product</name> <name>!product</name>
</property> </property>
</activation> </activation>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-ui</artifactId>
</dependency>
</dependencies>
<build> <build>
<resources> <resources>
<resource> <resource>
<directory>src/main/resources-community</directory> <directory>src/main/resources-community</directory>
</resource> </resource>
</resources> </resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack</id>
<phase>compile</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-ui</artifactId>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${project.build.directory}/classes/theme/keycloak.v2</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build> </build>
</profile> </profile>
<profile> <profile>