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),
ACCOUNT_API(Type.DEFAULT),
ADMIN_FINE_GRAINED_AUTHZ(Type.PREVIEW),
ADMIN2(Type.EXPERIMENTAL),
DOCKER(Type.DISABLED_BY_DEFAULT),
IMPERSONATION(Type.DEFAULT),
OPENSHIFT_INTEGRATION(Type.PREVIEW),

View file

@ -21,8 +21,7 @@ public class ProfileTest {
@Test
public void checkDefaultsKeycloak() {
Assert.assertEquals("community", Profile.getName());
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.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.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);
@ -38,8 +37,7 @@ public class ProfileTest {
Profile.init();
Assert.assertEquals("product", Profile.getName());
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.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.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);

View file

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

View file

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

View file

@ -167,14 +167,9 @@ public class ServerInfoAdminResource {
info.setThemes(new HashMap<>());
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);
if (!Profile.isFeatureEnabled(Profile.Feature.ACCOUNT2)) {
themeNames.remove("keycloak.v2");
themeNames.remove("rh-sso.v2");
}
List<ThemeInfoRepresentation> themes = new LinkedList<>();
info.getThemes().put(type.toString().toLowerCase(), themes);
@ -196,6 +191,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) {
info.setSocialProviders(new LinkedList<>());

View file

@ -1,6 +1,5 @@
<?xml version="1.0"?>
<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">
<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">
<parent>
<artifactId>keycloak-parent</artifactId>
<groupId>org.keycloak</groupId>
@ -10,7 +9,7 @@
<artifactId>keycloak-themes</artifactId>
<name>Keycloak Themes</name>
<description/>
<description />
<packaging>jar</packaging>
<properties>
@ -19,6 +18,20 @@
<args.npm.install>ci --no-optional --ignore-scripts</args.npm.install>
</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>
<plugins>
<plugin>
@ -122,10 +135,10 @@
<exclude>**/Gruntfile.js</exclude>
<exclude>**/Gemfile*</exclude>
<exclude>**/.*</exclude>
<!-- Remove once rcue stops shipping this file -->
<exclude>**/git-Logo.svg</exclude>
<exclude>**/keycloak.v2/account/src/**</exclude>
</excludes>
</resource>
@ -140,12 +153,44 @@
<name>!product</name>
</property>
</activation>
<dependencies>
<dependency>
<groupId>org.keycloak</groupId>
<artifactId>keycloak-admin-ui</artifactId>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources-community</directory>
</resource>
</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>
</profile>
<profile>
@ -243,4 +288,4 @@
</profile>
</profiles>
</project>
</project>