8000 Promote declarative-ui from experimental to supported by edewit · Pull Request #54150 · keycloak/keycloak · GitHub
[go: up one dir, main page]

Skip to content
Open
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
2 changes: 1 addition & 1 deletion .github/workflows/js-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ jobs:
- name: Start Keycloak server
run: |
tar xfvz keycloak-999.0.0-SNAPSHOT.tar.gz
keycloak-999.0.0-SNAPSHOT/bin/kc.sh start-dev --http-port 8180 --features transient-users,oid4vc-vci,oid4vc-vci-rest-credential-offer,declarative-ui,quick-theme,spiffe,kubernetes-service-accounts,workflows,client-auth-federated,jwt-authorization-grant,client-admin-api:v2 &> ~/server.log &
keycloak-999.0.0-SNAPSHOT/bin/kc.sh start-dev --http-port 8180 --features transient-users,oid4vc-vci,oid4vc-vci-rest-credential-offer,quick-theme,spiffe,kubernetes-service-accounts,workflows,client-auth-federated,jwt-authorization-grant,client-admin-api:v2 &> ~/server.log &
curl --connect-timeout 5 --max-time 10 --retry 10 --retry-all-errors --retry-delay 10 --retry-max-time 120 -s -o /dev/null http://127.0.0.1:8180
env:
KC_BOOTSTRAP_ADMIN_USERNAME: admin
Expand Down
2 changes: 1 addition & 1 deletion common/src/main/java/org/keycloak/common/Profile.java
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ public enum Feature {
OPENTELEMETRY_LOGS("OpenTelemetry Logs support", Type.PREVIEW, OPENTELEMETRY),
OPENTELEMETRY_METRICS("Micrometer to OpenTelemetry bridge support for metrics", Type.EXPERIMENTAL, OPENTELEMETRY),

DECLARATIVE_UI("declarative ui spi", Type.EXPERIMENTAL),
DECLARATIVE_UI("Declarative UI SPI", Type.DEFAULT),

ORGANIZATION("Organization support within realms", Type.DEFAULT),

Expand Down
12 changes: 12 additions & 0 deletions docs/documentation/release_notes/topics/27_0_0.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -73,3 +73,15 @@ Each accepted type of that credential therefore links its own identity.
The claim must be unique across all trusted issuers of a type, since any of them can issue a credential with that value.
Links to an OID4VP identity provider created by an earlier version no longer match and block the first broker login of their users, so remove them.
Only credentials in the `dc+sd-jwt` format can be requested.

= Extension Development

== Extend the Admin Console with the Declarative UI SPI (supported)
// https://github.com/keycloak/keycloak/issues/54149

Adding configuration screens to the Admin Console previously required maintaining a custom React theme for even simple provider forms.
The Declarative UI SPI lets extensions describe Admin Console pages and tabs in Java with `UiPageProvider` and `UiTabProvider`, and {project_name} renders those forms automatically.

In this release, the `declarative-ui` feature is promoted from experimental to supported and is enabled by default.

For more details, see the link:{ui_customization_guide_link}declarative-ui[Extending the Admin Console with the Declarative UI SPI] guide.
3 changes: 3 additions & 0 deletions docs/documentation/tests/src/test/resources/ignored-links
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,6 @@ https://hosted.weblate.org/projects/keycloak/
https://docs.redhat.com/*
# Blocks automated HTTP requests from CI runners (returns 403), but loads fine in a browser.
https://developer.linkedin.com*

# Remove after 27.0 release
https://www.keycloak.org/ui-customization/declarative-ui
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,14 @@ on an affected client, set `post.logout.redirect.uris` to `-`; otherwise, update
its post-logout redirect URIs to satisfy those rules. Setting `-` also works
after upgrading, so an affected client can still be remediated.

=== Declarative UI SPI enabled by default
// https://github.com/keycloak/keycloak/issues/54149

The `declarative-ui` feature is now supported and enabled by default.
You no longer need to start the server with `--features=declarative-ui` to use `UiPageProvider` and `UiTabProvider` extensions.
If you previously enabled the feature explicitly, you can remove that option from your configuration.
To disable the feature, start the server with `--features-disabled=declarative-ui`.

=== Scope mapping listings filter roles by visibility
// https://github.com/keycloak/keycloak/issues/53480

Expand Down
156 changes: 156 additions & 0 deletions docs/guides/ui-customization/declarative-ui.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
<#import "/templates/guide.adoc" as tmpl>
<#import "/templates/links.adoc" as links>

<@tmpl.guide
title="Extending the Admin Console with the Declarative UI SPI"
priority=40
summary="Add Admin Console pages and tabs from a Java SPI without a custom React theme.">

You can extend the Admin Console by implementing the Declarative UI SPI.
Instead of forking the Admin Console React theme, you describe forms and navigation in Java.
{project_name} renders those forms in the Admin Console and stores the submitted values as components.

Use this SPI when you need a configuration UI for a custom provider, or when you want a simple master-detail page in the Admin Console menu.

There are two provider types:

* `org.keycloak.services.ui.extend.UiPageProvider` — adds a top-level section in the Admin Console side menu, with a list view and a detail form
* `org.keycloak.services.ui.extend.UiTabProvider` — adds a tab on an existing Admin Console page

Both use `org.keycloak.provider.ProviderConfigProperty` (typically via `ProviderConfigurationBuilder`) to declare the fields on the form.

A full working example is available in the https://github.com/keycloak/keycloak-quickstarts/tree/main/extension/extend-admin-console-spi[extend-admin-console-spi] Keycloak quickstart.

== Adding a top-level page

Implement `UiPageProvider` and `UiPageProviderFactory`.
Register the factory with the Java ServiceLoader under `META-INF/services/org.keycloak.services.ui.extend.UiPageProviderFactory`.

The provider ID becomes the menu label.
`getHelpText()` is shown on the page.
`getConfigProperties()` defines the fields on the create and edit form.
Optionally override `getTypeMetadata()` and set `displayFields` to choose which fields appear as columns in the list view.

.Example page provider
[source,java]
----
public class TodoPage implements UiPageProvider, UiPageProviderFactory<ComponentModel> {

@Override
public String getId() {
return "Todo";
}

@Override
public String getHelpText() {
return "Store todo items for this realm";
}

@Override
public List<ProviderConfigProperty> getConfigProperties() {
return ProviderConfigurationBuilder.create()
.property()
.name("name")
.label("Name")
.helpText("Short name of the task")
.type(ProviderConfigProperty.STRING_TYPE)
.add()
.property()
.name("prio")
.label("Priority")
.type(ProviderConfigProperty.LIST_TYPE)
.options("critical", "high priority", "neutral", "low priority")
.add()
.build();
}

@Override
public Map<String, Object> getTypeMetadata() {
Map<String, Object> metaData = new HashMap<>();
metaData.put("displayFields", List.of("name", "prio"));
return metaData;
}

// implement init, postInit, and close as needed
}
----

== Adding a tab to an existing page

Implement `UiTabProvider` and `UiTabProviderFactory`.
Register the factory under `META-INF/services/org.keycloak.services.ui.extend.UiTabProviderFactory`.

`getPath()` must match a route pattern used by the Admin Console.
Valid paths are defined in the `routes` modules of the Admin Console source.
`getParams()` supplies the path parameters, including the tab identifier.

You can react to create, update, and delete through the component lifecycle callbacks on the factory, such as `onCreate` and `onUpdate`.
After the first save, the Admin Console updates the existing component, so override `onUpdate` whenever you need side effects on later edits.

.Example tab provider
[source,java]
----
public class AttributesTab implements UiTabProvider, UiTabProviderFactory<ComponentModel> {

@Override
public String getId() {
return "Attributes";
}

@Override
public String getPath() {
return "/:realm/realm-settings/:tab";
}

@Override
public Map<String, String> getParams() {
Map<String, String> params = new HashMap<>();
params.put("tab", "attributes");
return params;
}

@Override
public List<ProviderConfigProperty> getConfigProperties() {
return ProviderConfigurationBuilder.create()
.property()
.name("logo")
.label("Logo")
.helpText("Logo URL stored as a realm attribute for custom integrations")
.type(ProviderConfigProperty.STRING_TYPE)
.add()
.build();
}

@Override
public void onCreate(KeycloakSession session, RealmModel realm, ComponentModel model) {
realm.setAttribute("logo", model.get("logo"));
}

@Override
public void onUpdate(KeycloakSession session, RealmModel realm, ComponentModel oldModel, ComponentModel newModel) {
realm.setAttribute("logo", newModel.get("logo"));
}

// implement remaining Provider methods as needed
}
----

This example stores the value as the realm `logo` attribute so custom themes or extensions can read it.
The built-in Account Console logo comes from theme properties (`properties.logo`), not from that realm attribute, so you still need theme integration if you want the Account Console to display it.

== Packaging and deploying

Package the providers in a JAR with the ServiceLoader descriptors and copy the JAR to the `providers/` directory of the {project_name} server.
If you start the server with `--optimized`, run `bin/kc.[sh|bat] build` first so the provider registry picks up the new JAR, then restart the server.
Otherwise a normal restart is enough for {project_name} to discover the providers.
For details on packaging providers, see the link:{server_providers}[Service Provider Interfaces] chapter in the {developerguide_name}.

The Declarative UI SPI is enabled by default.
To disable it, start the server with:

[source,bash]
----
bin/kc.[sh|bat] start --features-disabled=declarative-ui
----

</@tmpl.guide>
2 changes: 2 additions & 0 deletions docs/guides/ui-customization/introduction.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,7 @@ summary="Learn how to customize the user interfaces.">

You can customize, extend, and modify these UIs to accommodate many use cases on your production systems. At a minimum, you will need to change the logos and colors to match your corporate identity. Also, you may modify the UIs to implement new functionality.

To add Admin Console pages or tabs from a Java provider without maintaining a custom React theme, see <@links.uicustomization id="declarative-ui"/>.

This guide provides all the information needed to customize the {project_name} UIs for your needs.
</@tmpl.guide>
2 changes: 1 addition & 1 deletion js/apps/keycloak-server/scripts/start-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ async function startServer() {
path.join(SERVER_DIR, `bin/kc${SCRIPT_EXTENSION}`),
[
"start-dev",
`--features="ssf,transient-users,oid4vc-vci,oid4vc-vp,declarative-ui,quick-theme,spiffe,kubernetes-service-accounts,workflows,client-auth-federated,openapi,client-admin-api:v2,resource-indicators"`,
`--features="ssf,transient-users,oid4vc-vci,oid4vc-vp,quick-theme,spiffe,kubernetes-service-accounts,workflows,client-auth-federated,openapi,client-admin-api:v2,resource-indicators"`,
"--openapi-enabled=true",
...keycloakArgs,
],
Expand Down
2 changes: 1 addition & 1 deletion js/libs/keycloak-admin-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ pnpm start --http-port 8180
If you started your container manually make sure there is an admin user named `admin` with password `admin`, the server is started in development mode using port 8180 and the required features are enabled.

```bash
./kc.sh start-dev --http-port 8180 --features transient-users,oid4vc-vci,declarative-ui,quick-theme,spiffe,kubernetes-service-accounts,workflows,client-auth-federated,jwt-authorization-grant
./kc.sh start-dev --http-port 8180 --features transient-users,oid4vc-vci,quick-theme,spiffe,kubernetes-service-accounts,workflows,client-auth-federated,jwt-authorization-grant
```

Then start the tests with:
Expand Down
Loading
0