forked from quarkusio/quarkus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support OidcProviderClient injection and token revocation
- Loading branch information
1 parent
e7b3e25
commit 5d751e0
Showing
16 changed files
with
219 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...c/runtime/src/main/java/io/quarkus/oidc/runtime/OidcConfigurationAndProviderProducer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package io.quarkus.oidc.runtime; | ||
|
||
import jakarta.enterprise.context.RequestScoped; | ||
import jakarta.enterprise.inject.Produces; | ||
import jakarta.inject.Inject; | ||
|
||
import io.quarkus.oidc.OIDCException; | ||
import io.quarkus.oidc.OidcConfigurationMetadata; | ||
import io.quarkus.security.identity.SecurityIdentity; | ||
|
||
@RequestScoped | ||
public class OidcConfigurationAndProviderProducer { | ||
@Inject | ||
TenantConfigBean tenantConfig; | ||
@Inject | ||
SecurityIdentity identity; | ||
|
||
@Produces | ||
@RequestScoped | ||
OidcConfigurationMetadata produceMetadata() { | ||
OidcConfigurationMetadata configMetadata = OidcUtils.getAttribute(identity, OidcUtils.CONFIG_METADATA_ATTRIBUTE); | ||
|
||
if (configMetadata == null && tenantConfig.getDefaultTenant().oidcConfig().tenantEnabled()) { | ||
configMetadata = tenantConfig.getDefaultTenant().provider().getMetadata(); | ||
} | ||
if (configMetadata == null) { | ||
throw new OIDCException("OidcConfigurationMetadata can not be injected"); | ||
} | ||
return configMetadata; | ||
} | ||
|
||
@Produces | ||
@RequestScoped | ||
OidcProviderClient produceProviderClient() { | ||
OidcProviderClient client = null; | ||
String tenantId = OidcUtils.getAttribute(identity, OidcUtils.TENANT_ID_ATTRIBUTE); | ||
if (tenantId != null) { | ||
if (OidcUtils.DEFAULT_TENANT_ID.equals(tenantId)) { | ||
return tenantConfig.getDefaultTenant().getOidcProviderClient(); | ||
} | ||
TenantConfigContext context = tenantConfig.getStaticTenant(tenantId); | ||
if (context == null) { | ||
context = tenantConfig.getDynamicTenant(tenantId); | ||
} | ||
if (context != null) { | ||
client = context.getOidcProviderClient(); | ||
} | ||
} | ||
if (client == null) { | ||
throw new OIDCException("OidcProviderClient can not be injected"); | ||
} | ||
return client; | ||
} | ||
} |
31 changes: 0 additions & 31 deletions
31
...oidc/runtime/src/main/java/io/quarkus/oidc/runtime/OidcConfigurationMetadataProducer.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.