Skip to content

Commit

Permalink
Add a quarkus-oidc-client-registration extension
Browse files Browse the repository at this point in the history
  • Loading branch information
sberyozkin committed Jul 14, 2024
1 parent 29a8cf8 commit 4a13c45
Show file tree
Hide file tree
Showing 50 changed files with 4,450 additions and 111 deletions.
10 changes: 10 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,16 @@
<artifactId>quarkus-rest-client-oidc-filter-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-registration</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-registration-deployment</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-graphql</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public enum Feature {
OBSERVABILITY,
OIDC,
OIDC_CLIENT,
OIDC_CLIENT_REGISTRATION,
RESTEASY_CLIENT_OIDC_FILTER,
REST_CLIENT_OIDC_FILTER,
OIDC_CLIENT_GRAPHQL_CLIENT_INTEGRATION,
Expand Down
13 changes: 13 additions & 0 deletions devtools/bom-descriptor-json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1721,6 +1721,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-registration</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-common</artifactId>
Expand Down
13 changes: 13 additions & 0 deletions docs/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1733,6 +1733,19 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-registration-deployment</artifactId>
<version>${project.version}</version>
<type>pom</type>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>*</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-common-deployment</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,279 @@
////
This guide is maintained in the main Quarkus repository
and pull requests should be submitted there:
https://github.com/quarkusio/quarkus/tree/main/docs/src/main/asciidoc
////
= OpenID Connect (OIDC) and OAuth2 dynamic client registration
include::_attributes.adoc[]
:diataxis-type: reference
:categories: security
:topics: security,oidc,client
:extensions: io.quarkus:quarkus-oidc-client-registration

Typically, you have to register an OIDC client (application) manually in your OIDC provider's dashboard.
During this process, you specify the human readable application name, allowed redirect and post logout URLs, and other properties.
After the registration has been completed, you copy the generated client id and secret to your Quarkus OIDC application properties.

OpenID Connect and OAuth2 dynamic client registration allows you to register OIDC clients dynamically, and manage individual client registrations.
You can read more about it in the https://openid.net/specs/openid-connect-registration-1_0.html[OIDC client registration] and https://datatracker.ietf.org/doc/html/rfc7592[OAuth2 Dynamic Client Registration Management Protocol] specification documents.

You can use Quarkus extension for OpenID Connect dynamic client registration and management.

This includes the following:

- Using `quarkus-oidc-client-registration` to register one or more clients using OIDC client registration configurations, either on start-up or on demand, and read, update and delete metadata of the registered clients. xref:security-openid-connect-multitenancy#tenant-config-resolver[OIDC TenantConfigResolver] can be used to create OIDC tenant configurations using the metadata of the registered clients.

Check warning on line 24 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 24, "column": 76}}}, "severity": "INFO"}

Check warning on line 24 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 24, "column": 361}}}, "severity": "INFO"}

== Oidc Client Registration

Check warning on line 26 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Headings] Use sentence-style capitalization in 'Oidc Client Registration'. Raw Output: {"message": "[Quarkus.Headings] Use sentence-style capitalization in 'Oidc Client Registration'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 26, "column": 4}}}, "severity": "INFO"}

Check warning on line 26 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spelling] Use correct American English spelling. Did you really mean 'Oidc'? Raw Output: {"message": "[Quarkus.Spelling] Use correct American English spelling. Did you really mean 'Oidc'?", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 26, "column": 4}}}, "severity": "WARNING"}

Add the following dependency:

[source,xml]
----
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-oidc-client-registration</artifactId>
</dependency>
----

The `quarkus-oidc-client-registration` extension allows register one or more clients using OIDC client registration configurations, either on start-up or on demand, and read, update and delete metadata of the registered clients.

Check warning on line 38 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 38, "column": 85}}}, "severity": "INFO"}

You can register and manage client registrations from the custom xref:security-openid-connect-multitenancy#tenant-config-resolver[OIDC TenantConfigResolver].
Alternatively, you can register clients without even using OIDC. For example, it can be a command line tool which registers clients and passes metadata of the registered clients to Quarkus services which require them.

Check warning on line 41 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using 'by using' or 'that uses' rather than 'using'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 41, "column": 53}}}, "severity": "INFO"}

Check warning on line 41 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 41, "column": 108}}}, "severity": "INFO"}

Check warning on line 41 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'. Raw Output: {"message": "[Quarkus.TermsSuggestions] Depending on the context, consider using ', which (non restrictive clause preceded by a comma)' or 'that (restrictive clause without a comma)' rather than 'which'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 41, "column": 198}}}, "severity": "INFO"}


=== Register clients on start-up

You start with declaring one or more OIDC client registration configurations, for example:

[source,properties]
----
# Default OIDC client registration which auto-discovers a standard client registration endpoint.
# It does not require an initial registration token.
quarkus.oidc-client-registration.auth-server-url=${quarkus.oidc.auth-server-url}
quarkus.oidc-client-registration.metadata.client-name=Default Client
quarkus.oidc-client-registration.metadata.redirect-uri=http://localhost:8081/protected
# Named OIDC client registration which configures a registration endpoint path:
# It require an initial registration token for a client registration to succeed.
quarkus.oidc-client-registration.tenant-client.registration-path=${quarkus.oidc.auth-server-url}/clients-registrations/openid-connect
quarkus.oidc-client-registration.tenant-client.metadata.client-name=Tenant Client
quarkus.oidc-client-registration.tenant-client.metadata.redirect-uri=http://localhost:8081/protected/tenant
quarkus.oidc-client-registration.initial-token=${initial-registration-token}
----

The above configuration will lead to two new client registrations created in your OIDC provider.

You or may not need to acquire an initial registration access token. If you don't, then you will have to enable one or more client registration policies in your OIDC provider's dashboard. For example, see https://www.keycloak.org/docs/latest/securing_apps/#_client_registration_policies[Keycloak client registration policies].

Check warning on line 68 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.TermsWarnings] Consider using 'might (for possiblity)' or 'can (for ability)' rather than 'may' unless updating existing content that uses the term. Raw Output: {"message": "[Quarkus.TermsWarnings] Consider using 'might (for possiblity)' or 'can (for ability)' rather than 'may' unless updating existing content that uses the term.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 68, "column": 8}}}, "severity": "WARNING"}

Check warning on line 68 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'need to'. Raw Output: {"message": "[Quarkus.Fluff] Depending on the context, consider using 'Rewrite the sentence, or use 'must', instead of' rather than 'need to'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 68, "column": 16}}}, "severity": "INFO"}

The next step is to inject either `quarkus.oidc.client.registration.OidcClientRegistration` if only a single default client registration is done, or `quarkus.oidc.client.registration.OidcClientRegistrations` if more than one registration is configured, and use metadata of these registered clients.

For example:

[source,java]
----
package io.quarkus.it.keycloak;
import java.net.URI;
import java.util.List;
import java.util.Optional;
import jakarta.enterprise.event.Observes;
import jakarta.inject.Inject;
import jakarta.inject.Singleton;
import jakarta.json.Json;
import org.eclipse.microprofile.config.inject.ConfigProperty;
import io.quarkus.oidc.OidcRequestContext;
import io.quarkus.oidc.OidcTenantConfig;
import io.quarkus.oidc.OidcTenantConfig.ApplicationType;
import io.quarkus.oidc.TenantConfigResolver;
import io.quarkus.oidc.client.registration.ClientMetadata;
import io.quarkus.oidc.client.registration.OidcClientRegistration;
import io.quarkus.oidc.client.registration.OidcClientRegistrationConfig;
import io.quarkus.oidc.client.registration.OidcClientRegistrations;
import io.quarkus.oidc.client.registration.RegisteredClient;
import io.quarkus.oidc.common.runtime.OidcConstants;
import io.quarkus.runtime.ShutdownEvent;
import io.smallrye.mutiny.Uni;
import io.vertx.ext.web.RoutingContext;
@Singleton
public class CustomTenantConfigResolver implements TenantConfigResolver {
@Inject
OidcClientRegistration clientReg;
@Inject
OidcClientRegistrations clientRegs;
@Override
public Uni<OidcTenantConfig> resolve(RoutingContext routingContext,
OidcRequestContext<OidcTenantConfig> requestContext) {
if (routingContext.request().path().endsWith("/protected")) {
return Uni.createFrom().item(createTenantConfig("registered-client", clientReg.registeredClient()));
} else if (routingContext.request().path().endsWith("/protected/tenant")) {
return Uni.createFrom().item(createTenantConfig("registered-client-tenant",
clientRegs.getClientRegistration("tenant-client").registeredClient()));
}
return null;
}
private OidcTenantConfig createTenantConfig(String tenantId, RegisteredClient client) {
ClientMetadata metadata = client.getMetadata();
OidcTenantConfig oidcConfig = new OidcTenantConfig();
oidcConfig.setTenantId(tenantId);
oidcConfig.setAuthServerUrl(authServerUrl);
oidcConfig.setApplicationType(ApplicationType.WEB_APP);
oidcConfig.setClientName(metadata.getClientName());
oidcConfig.setClientId(metadata.getClientId());
oidcConfig.getCredentials().setSecret(metadata.getClientSecret());
String redirectUri = metadata.getRedirectUris().get(0);
oidcConfig.getAuthentication().setRedirectPath(URI.create(redirectUri).getPath());
return oidcConfig;
}
}
----

=== Register clients on demand

You can register new clients on demand.
You can add new clients to the existing, already configured `OidcClientConfiguration` or to a newly created `OidcClientConfiguration`.

Configure one or more OIDC client registrations:

[source,properties]
----
quarkus.oidc-client-registration.auth-server-url=${quarkus.oidc.auth-server-url}
---
The above configuration is sufficient for registering new clients using this configuration. For example:
[source,java]
----
package io.quarkus.it.keycloak;

import java.net.URI;

Check failure on line 159 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 't.U'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 't.U'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 159, "column": 15}}}, "severity": "ERROR"}
import java.util.List;

Check failure on line 160 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 'l.L'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 'l.L'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 160, "column": 16}}}, "severity": "ERROR"}
import java.util.Map;

Check failure on line 161 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 'l.M'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 'l.M'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 161, "column": 16}}}, "severity": "ERROR"}
import java.util.Optional;

Check failure on line 162 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 'l.O'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 'l.O'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 162, "column": 16}}}, "severity": "ERROR"}

import jakarta.enterprise.event.Observes;

Check failure on line 164 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 't.O'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 't.O'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 164, "column": 31}}}, "severity": "ERROR"}
import jakarta.inject.Inject;

Check failure on line 165 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 't.I'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 't.I'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 165, "column": 21}}}, "severity": "ERROR"}
import jakarta.inject.Singleton;

Check failure on line 166 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 't.S'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 't.S'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 166, "column": 21}}}, "severity": "ERROR"}
import jakarta.json.Json;

Check failure on line 167 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 'n.J'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 'n.J'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 167, "column": 19}}}, "severity": "ERROR"}

import org.eclipse.microprofile.config.inject.ConfigProperty;

Check failure on line 169 in docs/src/main/asciidoc/security-openid-connect-client-registration.adoc

View workflow job for this annotation

GitHub Actions / Linting with Vale

[vale] reported by reviewdog 🐶 [Quarkus.Spacing] Keep one space between words in 't.C'. Raw Output: {"message": "[Quarkus.Spacing] Keep one space between words in 't.C'.", "location": {"path": "docs/src/main/asciidoc/security-openid-connect-client-registration.adoc", "range": {"start": {"line": 169, "column": 45}}}, "severity": "ERROR"}

import io.quarkus.oidc.OidcRequestContext;
import io.quarkus.oidc.OidcTenantConfig;
import io.quarkus.oidc.OidcTenantConfig.ApplicationType;
import io.quarkus.oidc.TenantConfigResolver;
import io.quarkus.oidc.client.registration.ClientMetadata;
import io.quarkus.oidc.client.registration.OidcClientRegistration;
import io.quarkus.oidc.client.registration.OidcClientRegistrations;
import io.quarkus.oidc.client.registration.OidcClientRegistrationConfig;
import io.quarkus.oidc.common.runtime.OidcConstants;
import io.quarkus.runtime.StartupEvent;
import io.smallrye.mutiny.Uni;
import io.vertx.ext.web.RoutingContext;

@Singleton
public class CustomTenantConfigResolver implements TenantConfigResolver {

@Inject
OidcClientRegistration clientReg;

@Inject
OidcClientRegistrations clientRegs;

@Inject
@ConfigProperty(name = "quarkus.oidc.auth-server-url")
String authServerUrl;

volatile Map<String, RegisteredClient> regClientsMulti;

void onStartup(@Observes StartupEvent event) {
// Two custom OIDC client registrations registered right now
ClientMetadata clientMetadataMulti1 = createMetadata("http://localhost:8081/protected/multi1", "Multi1 Client");
ClientMetadata clientMetadataMulti2 = createMetadata("http://localhost:8081/protected/multi2", "Multi2 Client");

Map<String, RegisteredClient> regClientsMulti = clientReg.registerClients(List.of(clientMetadataMulti1, clientMetadataMulti2))
.collect().asMap(r -> URI.create(r.metadata().getRedirectUris().get(0)).getPath(), r -> r)
.await().indefinitely();
}


@Override
public Uni<OidcTenantConfig> resolve(RoutingContext routingContext,
OidcRequestContext<OidcTenantConfig> requestContext) {
if (routingContext.request().path().endsWith("/protected/new-oidc-client-reg")) {
// New client registration done dynamically at the request time

OidcClientRegistrationConfig clientRegConfig = new OidcClientRegistrationConfig();
clientRegConfig.auth-server-url = Optional.of(authServerUrl);
clientRegConfig.metadata.redirectUri = Optional.of("http://localhost:8081/protected/new-oidc-client-reg");
clientRegConfig.metadata.clientName = Optional.of("Dynamic Client");

return clientRegs.newClientRegistration(clientRegConfig)
.onItem().transform(reg ->
createTenantConfig("registered-client-dynamically", reg.registeredClient());
} if (routingContext.request().path().endsWith("/protected/oidc-client-reg-existing-config")) {
// New client registration done dynamically at the request time using the configured client registration

ClientMetadata metadata = createMetadata("http://localhost:8081/protected/dynamic-tenant",
"Dynamic Tenant Client");

return clientReg.registerClient(metadata).onItem().transform(r ->
createTenantConfig("registered-client-dynamically", r));

} else if (routingContext.request().path().endsWith("/protected/multi1")) {
return Uni.createFrom().item(createTenantConfig("registered-client-multi1",
regClientsMulti.get("/protected/multi1").metadata()));
} else if (routingContext.request().path().endsWith("/protected/multi2")) {
return Uni.createFrom().item(createTenantConfig("registered-client-multi2",
regClientsMulti.get("/protected/multi2").metadata()));
}

return null;
}

private OidcTenantConfig createTenantConfig(String tenantId, ClientMetadata metadata) {
OidcTenantConfig oidcConfig = new OidcTenantConfig();
oidcConfig.setTenantId(tenantId);
oidcConfig.setAuthServerUrl(authServerUrl);
oidcConfig.setApplicationType(ApplicationType.WEB_APP);
oidcConfig.setClientName(metadata.getClientName());
oidcConfig.setClientId(metadata.getClientId());
oidcConfig.getCredentials().setSecret(metadata.getClientSecret());
String redirectUri = metadata.getRedirectUris().get(0);
oidcConfig.getAuthentication().setRedirectPath(URI.create(redirectUri).getPath());
return oidcConfig;
}

protected static ClientMetadata createMetadata(String redirectUri, String clientName) {
return new ClientMetadata(Json.createObjectBuilder()
.add(OidcConstants.CLIENT_METADATA_REDIRECT_URIS, Json.createArrayBuilder().add(redirectUri))
.add(OidcConstants.CLIENT_METADATA_CLIENT_NAME, clientName)
.build());
}
}

----
[[configuration-reference]]
== Configuration reference
include::{generated-dir}/config/quarkus-oidc-client-registration.adoc[opts=optional, leveloffset=+1]
== References
* https://openid.net/specs/openid-connect-registration-1_0.html[OIDC client registration]
* https://datatracker.ietf.org/doc/html/rfc7592[OAuth2 Dynamic Client Registration Management Protocol]
* https://www.keycloak.org/docs/latest/securing_apps/#_client_registration[Keycloak Dynamic Client Registration Service]
* xref:security-oidc-bearer-token-authentication.adoc[OIDC Bearer token authentication]
* xref:security-oidc-code-flow-authentication.adoc[OIDC code flow mechanism for protecting web applications]
* xref:security-overview.adoc[Quarkus Security overview]
Loading

0 comments on commit 4a13c45

Please sign in to comment.