Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
package io.quarkus.oidc;
import java.nio.file.Path;
import java.time.Duration;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt;
import io.quarkus.oidc.common.runtime.OidcCommonConfig;
import io.quarkus.oidc.common.runtime.OidcConstants;
import io.quarkus.oidc.runtime.OidcConfig;
import io.quarkus.runtime.annotations.ConfigDocMapKey;
import io.quarkus.runtime.annotations.ConfigGroup;
import io.quarkus.runtime.annotations.ConfigItem;
import io.quarkus.runtime.annotations.ConvertWith;
import io.quarkus.runtime.configuration.TrimmedStringConverter;
import io.quarkus.security.identity.SecurityIdentityAugmentor;
@ConfigGroup
public class OidcTenantConfig extends OidcCommonConfig {
/**
* A unique tenant identifier. It can be set by {@code TenantConfigResolver} providers, which
* resolve the tenant configuration dynamically.
*/
@ConfigItem
public Optional tenantId = Optional.empty();
/**
* If this tenant configuration is enabled.
*
* The default tenant is disabled if it is not configured but
* a {@link TenantConfigResolver} that resolves tenant configurations is registered,
* or named tenants are configured.
* In this case, you do not need to disable the default tenant.
*/
@ConfigItem(defaultValue = "true")
public boolean tenantEnabled = true;
/**
* The application type, which can be one of the following {@link ApplicationType} values.
*/
@ConfigItem(defaultValueDocumentation = "service")
public Optional applicationType = Optional.empty();
/**
* The relative path or absolute URL of the OpenID Connect (OIDC) authorization endpoint, which authenticates
* users.
* You must set this property for `web-app` applications if OIDC discovery is disabled.
* This property is ignored if OIDC discovery is enabled.
*/
@ConfigItem
public Optional authorizationPath = Optional.empty();
/**
* The relative path or absolute URL of the OIDC UserInfo endpoint.
* You must set this property for `web-app` applications if OIDC discovery is disabled
* and the `authentication.user-info-required` property is enabled.
* This property is ignored if OIDC discovery is enabled.
*/
@ConfigItem
public Optional userInfoPath = Optional.empty();
/**
* Relative path or absolute URL of the OIDC RFC7662 introspection endpoint which can introspect both opaque and
* JSON Web Token (JWT) tokens.
* This property must be set if OIDC discovery is disabled and 1) the opaque bearer access tokens must be verified
* or 2) JWT tokens must be verified while the cached JWK verification set with no matching JWK is being refreshed.
* This property is ignored if the discovery is enabled.
*/
@ConfigItem
public Optional introspectionPath = Optional.empty();
/**
* Relative path or absolute URL of the OIDC JSON Web Key Set (JWKS) endpoint which returns a JSON Web Key
* Verification Set.
* This property should be set if OIDC discovery is disabled and the local JWT verification is required.
* This property is ignored if the discovery is enabled.
*/
@ConfigItem
public Optional jwksPath = Optional.empty();
/**
* Relative path or absolute URL of the OIDC end_session_endpoint.
* This property must be set if OIDC discovery is disabled and RP Initiated Logout support for the `web-app` applications is
* required.
* This property is ignored if the discovery is enabled.
*/
@ConfigItem
public Optional endSessionPath = Optional.empty();
/**
* The paths which must be secured by this tenant. Tenant with the most specific path wins.
* Please see the xref:security-openid-connect-multitenancy.adoc#configuration-based-tenant-resolver[Resolve with
* configuration]
* section of the OIDC multitenancy guide for explanation of allowed path patterns.
*
* @asciidoclet
*/
@ConfigItem
public Optional> tenantPaths = Optional.empty();
/**
* The public key for the local JWT token verification.
* OIDC server connection is not created when this property is set.
*/
@ConfigItem
public Optional publicKey = Optional.empty();
/**
* Introspection Basic Authentication which must be configured only if the introspection is required
* and OpenId Connect Provider does not support the OIDC client authentication configured with
* {@link OidcCommonConfig#credentials} for its introspection endpoint.
*/
@ConfigItem
public IntrospectionCredentials introspectionCredentials = new IntrospectionCredentials();
/**
* Introspection Basic Authentication configuration
*/
@ConfigGroup
public static class IntrospectionCredentials {
/**
* Name
*/
@ConfigItem
public Optional name = Optional.empty();
/**
* Secret
*/
@ConfigItem
public Optional secret = Optional.empty();
/**
* Include OpenId Connect Client ID configured with `quarkus.oidc.client-id`.
*/
@ConfigItem(defaultValue = "true")
public boolean includeClientId = true;
public Optional getName() {
return name;
}
public void setName(String name) {
this.name = Optional.of(name);
}
public Optional getSecret() {
return secret;
}
public void setSecret(String secret) {
this.secret = Optional.of(secret);
}
public boolean isIncludeClientId() {
return includeClientId;
}
public void setIncludeClientId(boolean includeClientId) {
this.includeClientId = includeClientId;
}
}
/**
* Configuration to find and parse a custom claim containing the roles information.
*/
@ConfigItem
public Roles roles = new Roles();
/**
* Configuration how to validate the token claims.
*/
@ConfigItem
public Token token = new Token();
/**
* RP Initiated, BackChannel and FrontChannel Logout configuration
*/
@ConfigItem
public Logout logout = new Logout();
/**
* Configuration of the certificate chain which can be used to verify tokens.
* If the certificate chain truststore is configured, the tokens can be verified using the certificate
* chain inlined in the Base64-encoded format as an `x5c` header in the token itself.
*
* The certificate chain inlined in the token is verified.
* Signature of every certificate in the chain but the root certificate is verified by the next certificate in the chain.
* Thumbprint of the root certificate in the chain must match a thumbprint of one of the certificates in the truststore.
*
* Additionally, a direct trust in the leaf chain certificate which will be used to verify the token signature must
* be established.
* By default, the leaf certificate's thumbprint must match a thumbprint of one of the certificates in the truststore.
* If the truststore does not have the leaf certificate imported, then the leaf certificate must be identified by its Common
* Name.
*/
@ConfigItem
public CertificateChain certificateChain = new CertificateChain();
@ConfigGroup
public static class CertificateChain {
/**
* Common name of the leaf certificate. It must be set if the {@link #trustStoreFile} does not have
* this certificate imported.
*
*/
@ConfigItem
public Optional leafCertificateName = Optional.empty();
/**
* Truststore file which keeps thumbprints of the trusted certificates.
*/
@ConfigItem
public Optional trustStoreFile = Optional.empty();
/**
* A parameter to specify the password of the truststore file if it is configured with {@link #trustStoreFile}.
*/
@ConfigItem
public Optional trustStorePassword = Optional.empty();
/**
* A parameter to specify the alias of the truststore certificate.
*/
@ConfigItem
public Optional trustStoreCertAlias = Optional.empty();
/**
* An optional parameter to specify type of the truststore file. If not given, the type is automatically
* detected
* based on the file name.
*/
@ConfigItem
public Optional trustStoreFileType = Optional.empty();
public Optional getTrustStoreFile() {
return trustStoreFile;
}
public void setTrustStoreFile(Path trustStoreFile) {
this.trustStoreFile = Optional.of(trustStoreFile);
}
public Optional getTrustStoreCertAlias() {
return trustStoreCertAlias;
}
public void setTrustStoreCertAlias(String trustStoreCertAlias) {
this.trustStoreCertAlias = Optional.of(trustStoreCertAlias);
}
public Optional getTrustStoreFileType() {
return trustStoreFileType;
}
public void setTrustStoreFileType(Optional trustStoreFileType) {
this.trustStoreFileType = trustStoreFileType;
}
public Optional getLeafCertificateName() {
return leafCertificateName;
}
public void setLeafCertificateName(String leafCertificateName) {
this.leafCertificateName = Optional.of(leafCertificateName);
}
public Optional getTrustStorePassword() {
return trustStorePassword;
}
public void setTrustStorePassword(String trustStorePassword) {
this.trustStorePassword = Optional.ofNullable(trustStorePassword);
}
}
/**
* Different options to configure authorization requests
*/
public Authentication authentication = new Authentication();
/**
* Authorization code grant configuration
*/
public CodeGrant codeGrant = new CodeGrant();
/**
* Default token state manager configuration
*/
@ConfigItem
public TokenStateManager tokenStateManager = new TokenStateManager();
/**
* Allow caching the token introspection data.
* Note enabling this property does not enable the cache itself but only permits to cache the token introspection
* for a given tenant. If the default token cache can be used, see {@link OidcConfig.TokenCache} to enable
* it.
*/
@ConfigItem(defaultValue = "true")
public boolean allowTokenIntrospectionCache = true;
/**
* Allow caching the user info data.
* Note enabling this property does not enable the cache itself but only permits to cache the user info data
* for a given tenant. If the default token cache can be used, see {@link OidcConfig.TokenCache} to enable
* it.
*/
@ConfigItem(defaultValue = "true")
public boolean allowUserInfoCache = true;
/**
* Allow inlining UserInfo in IdToken instead of caching it in the token cache.
* This property is only checked when an internal IdToken is generated when OAuth2 providers do not return IdToken.
* Inlining UserInfo in the generated IdToken allows to store it in the session cookie and avoids introducing a cached
* state.
*
* Inlining UserInfo in the generated IdToken is enabled if the session cookie is encrypted
* and the UserInfo cache is not enabled or caching UserInfo is disabled for the current tenant
* with the {@link #allowUserInfoCache} property set to `false`.
*/
@ConfigItem
public Optional cacheUserInfoInIdtoken = Optional.empty();
@ConfigGroup
public static class Logout {
/**
* The relative path of the logout endpoint at the application. If provided, the application is able to
* initiate the
* logout through this endpoint in conformance with the OpenID Connect RP-Initiated Logout specification.
*/
@ConfigItem
public Optional path = Optional.empty();
/**
* Relative path of the application endpoint where the user should be redirected to after logging out from the
* OpenID
* Connect Provider.
* This endpoint URI must be properly registered at the OpenID Connect Provider as a valid redirect URI.
*/
@ConfigItem
public Optional postLogoutPath = Optional.empty();
/**
* Name of the post logout URI parameter which is added as a query parameter to the logout redirect URI.
*/
@ConfigItem(defaultValue = OidcConstants.POST_LOGOUT_REDIRECT_URI)
public String postLogoutUriParam;
/**
* Additional properties which is added as the query parameters to the logout redirect URI.
*/
@ConfigItem
@ConfigDocMapKey("query-parameter-name")
public Map extraParams;
/**
* Back-Channel Logout configuration
*/
@ConfigItem
public Backchannel backchannel = new Backchannel();
/**
* Front-Channel Logout configuration
*/
@ConfigItem
public Frontchannel frontchannel = new Frontchannel();
public void setPath(Optional path) {
this.path = path;
}
public Optional getPath() {
return path;
}
public void setPostLogoutPath(Optional postLogoutPath) {
this.postLogoutPath = postLogoutPath;
}
public Optional getPostLogoutPath() {
return postLogoutPath;
}
public Map getExtraParams() {
return extraParams;
}
public void setExtraParams(Map extraParams) {
this.extraParams = extraParams;
}
public String getPostLogoutUriParam() {
return postLogoutUriParam;
}
public void setPostLogoutUriParam(String postLogoutUriParam) {
this.postLogoutUriParam = postLogoutUriParam;
}
public Backchannel getBackchannel() {
return backchannel;
}
public void setBackchannel(Backchannel backchannel) {
this.backchannel = backchannel;
}
public Frontchannel getFrontchannel() {
return frontchannel;
}
public void setFrontchannel(Frontchannel frontchannel) {
this.frontchannel = frontchannel;
}
}
@ConfigGroup
public static class Backchannel {
/**
* The relative path of the Back-Channel Logout endpoint at the application.
*/
@ConfigItem
public Optional path = Optional.empty();
/**
* Maximum number of logout tokens that can be cached before they are matched against ID tokens stored in session
* cookies.
*/
@ConfigItem(defaultValue = "10")
public int tokenCacheSize = 10;
/**
* Number of minutes a logout token can be cached for.
*/
@ConfigItem(defaultValue = "10M")
public Duration tokenCacheTimeToLive = Duration.ofMinutes(10);
/**
* Token cache timer interval.
* If this property is set, a timer checks and removes the stale entries periodically.
*/
@ConfigItem
public Optional cleanUpTimerInterval = Optional.empty();
/**
* Logout token claim whose value is used as a key for caching the tokens.
* Only `sub` (subject) and `sid` (session id) claims can be used as keys.
* Set it to `sid` only if ID tokens issued by the OIDC provider have no `sub` but have `sid` claim.
*/
@ConfigItem(defaultValue = "sub")
public String logoutTokenKey = "sub";
public void setPath(Optional path) {
this.path = path;
}
public Optional getPath() {
return path;
}
public String getLogoutTokenKey() {
return logoutTokenKey;
}
public void setLogoutTokenKey(String logoutTokenKey) {
this.logoutTokenKey = logoutTokenKey;
}
public int getTokenCacheSize() {
return tokenCacheSize;
}
public void setTokenCacheSize(int tokenCacheSize) {
this.tokenCacheSize = tokenCacheSize;
}
public Duration getTokenCacheTimeToLive() {
return tokenCacheTimeToLive;
}
public void setTokenCacheTimeToLive(Duration tokenCacheTimeToLive) {
this.tokenCacheTimeToLive = tokenCacheTimeToLive;
}
public Optional getCleanUpTimerInterval() {
return cleanUpTimerInterval;
}
public void setCleanUpTimerInterval(Duration cleanUpTimerInterval) {
this.cleanUpTimerInterval = Optional.of(cleanUpTimerInterval);
}
}
/**
* Configuration for controlling how JsonWebKeySet containing verification keys should be acquired and managed.
*/
@ConfigItem
public Jwks jwks = new Jwks();
@ConfigGroup
public static class Jwks {
/**
* If JWK verification keys should be fetched at the moment a connection to the OIDC provider
* is initialized.
*
* Disabling this property delays the key acquisition until the moment the current token
* has to be verified. Typically it can only be necessary if the token or other telated request properties
* provide an additional context which is required to resolve the keys correctly.
*/
@ConfigItem(defaultValue = "true")
public boolean resolveEarly = true;
/**
* Maximum number of JWK keys that can be cached.
* This property is ignored if the {@link #resolveEarly} property is set to true.
*/
@ConfigItem(defaultValue = "10")
public int cacheSize = 10;
/**
* Number of minutes a JWK key can be cached for.
* This property is ignored if the {@link #resolveEarly} property is set to true.
*/
@ConfigItem(defaultValue = "10M")
public Duration cacheTimeToLive = Duration.ofMinutes(10);
/**
* Cache timer interval.
* If this property is set, a timer checks and removes the stale entries periodically.
* This property is ignored if the {@link #resolveEarly} property is set to true.
*/
@ConfigItem
public Optional cleanUpTimerInterval = Optional.empty();
public int getCacheSize() {
return cacheSize;
}
public void setCacheSize(int cacheSize) {
this.cacheSize = cacheSize;
}
public Duration getCacheTimeToLive() {
return cacheTimeToLive;
}
public void setCacheTimeToLive(Duration cacheTimeToLive) {
this.cacheTimeToLive = cacheTimeToLive;
}
public Optional getCleanUpTimerInterval() {
return cleanUpTimerInterval;
}
public void setCleanUpTimerInterval(Duration cleanUpTimerInterval) {
this.cleanUpTimerInterval = Optional.of(cleanUpTimerInterval);
}
public boolean isResolveEarly() {
return resolveEarly;
}
public void setResolveEarly(boolean resolveEarly) {
this.resolveEarly = resolveEarly;
}
}
@ConfigGroup
public static class Frontchannel {
/**
* The relative path of the Front-Channel Logout endpoint at the application.
*/
@ConfigItem
public Optional path = Optional.empty();
public void setPath(Optional path) {
this.path = path;
}
public Optional getPath() {
return path;
}
}
/**
* Default Authorization Code token state manager configuration
*/
@ConfigGroup
public static class TokenStateManager {
public enum Strategy {
/**
* Keep ID, access and refresh tokens.
*/
KEEP_ALL_TOKENS,
/**
* Keep ID token only
*/
ID_TOKEN,
/**
* Keep ID and refresh tokens only
*/
ID_REFRESH_TOKENS
}
/**
* Default TokenStateManager strategy.
*/
@ConfigItem(defaultValue = "keep_all_tokens")
public Strategy strategy = Strategy.KEEP_ALL_TOKENS;
/**
* Default TokenStateManager keeps all tokens (ID, access and refresh)
* returned in the authorization code grant response in a single session cookie by default.
*
* Enable this property to minimize a session cookie size
*/
@ConfigItem(defaultValue = "false")
public boolean splitTokens;
/**
* Mandates that the Default TokenStateManager encrypt the session cookie that stores the tokens.
*/
@ConfigItem(defaultValue = "true")
public boolean encryptionRequired = true;
/**
* The secret used by the Default TokenStateManager to encrypt the session cookie
* storing the tokens when {@link #encryptionRequired} property is enabled.
*
* If this secret is not set, the client secret configured with
* either `quarkus.oidc.credentials.secret` or `quarkus.oidc.credentials.client-secret.value` is checked.
* Finally, `quarkus.oidc.credentials.jwt.secret` which can be used for `client_jwt_secret` authentication is
* checked.
* The secret is auto-generated every time an application starts if it remains uninitialized after checking all of these
* properties.
* Generated secret can not decrypt the session cookie encrypted before the restart, therefore a user re-authentication
* will be required.
*
* The length of the secret used to encrypt the tokens should be at least 32 characters long.
* A warning is logged if the secret length is less than 16 characters.
*/
@ConfigItem
public Optional encryptionSecret = Optional.empty();
/**
* Supported session cookie key encryption algorithms
*/
public static enum EncryptionAlgorithm {
/**
* Content encryption key will be generated and encrypted using the A256GCMKW algorithm and the configured
* encryption secret.
* The generated content encryption key will be used to encrypt the session cookie content.
*/
A256GCMKW,
/**
* The configured key encryption secret will be used as the content encryption key to encrypt the session cookie
* content.
* Using the direct encryption avoids a content encryption key generation step and
* will make the encrypted session cookie sequence slightly shorter.
*
* Avoid using the direct encryption if the encryption secret is less than 32 characters long.
*/
DIR;
}
/**
* Session cookie key encryption algorithm
*/
@ConfigItem(defaultValue = "A256GCMKW")
public EncryptionAlgorithm encryptionAlgorithm = EncryptionAlgorithm.A256GCMKW;
public boolean isEncryptionRequired() {
return encryptionRequired;
}
public void setEncryptionRequired(boolean encryptionRequired) {
this.encryptionRequired = encryptionRequired;
}
public Optional getEncryptionSecret() {
return encryptionSecret;
}
public void setEncryptionSecret(String encryptionSecret) {
this.encryptionSecret = Optional.of(encryptionSecret);
}
public boolean isSplitTokens() {
return splitTokens;
}
public void setSplitTokens(boolean splitTokens) {
this.splitTokens = splitTokens;
}
public Strategy getStrategy() {
return strategy;
}
public void setStrategy(Strategy strategy) {
this.strategy = strategy;
}
public EncryptionAlgorithm getEncryptionAlgorithm() {
return encryptionAlgorithm;
}
public void setEncryptionAlgorithm(EncryptionAlgorithm encryptionAlgorithm) {
this.encryptionAlgorithm = encryptionAlgorithm;
}
}
public Optional getAuthorizationPath() {
return authorizationPath;
}
public void setAuthorizationPath(String authorizationPath) {
this.authorizationPath = Optional.of(authorizationPath);
}
public Optional getUserInfoPath() {
return userInfoPath;
}
public void setUserInfoPath(String userInfoPath) {
this.userInfoPath = Optional.of(userInfoPath);
}
public Optional getIntrospectionPath() {
return introspectionPath;
}
public void setIntrospectionPath(String introspectionPath) {
this.introspectionPath = Optional.of(introspectionPath);
}
public Optional getJwksPath() {
return jwksPath;
}
public void setJwksPath(String jwksPath) {
this.jwksPath = Optional.of(jwksPath);
}
public Optional getEndSessionPath() {
return endSessionPath;
}
public void setEndSessionPath(String endSessionPath) {
this.endSessionPath = Optional.of(endSessionPath);
}
public Optional getPublicKey() {
return publicKey;
}
public void setPublicKey(String publicKey) {
this.publicKey = Optional.of(publicKey);
}
public Roles getRoles() {
return roles;
}
public void setRoles(Roles roles) {
this.roles = roles;
}
public Token getToken() {
return token;
}
public void setToken(Token token) {
this.token = token;
}
public Authentication getAuthentication() {
return authentication;
}
public void setAuthentication(Authentication authentication) {
this.authentication = authentication;
}
public Optional getTenantId() {
return tenantId;
}
public void setTenantId(String tenantId) {
this.tenantId = Optional.of(tenantId);
}
public boolean isTenantEnabled() {
return tenantEnabled;
}
public void setTenantEnabled(boolean enabled) {
this.tenantEnabled = enabled;
}
public void setLogout(Logout logout) {
this.logout = logout;
}
public Logout getLogout() {
return logout;
}
@ConfigGroup
public static class Roles {
public static Roles fromClaimPath(List path) {
return fromClaimPathAndSeparator(path, null);
}
public static Roles fromClaimPathAndSeparator(List path, String sep) {
Roles roles = new Roles();
roles.roleClaimPath = Optional.ofNullable(path);
roles.roleClaimSeparator = Optional.ofNullable(sep);
return roles;
}
/**
* A list of paths to claims containing an array of groups.
* Each path starts from the top level JWT JSON object
* and can contain multiple segments.
* Each segment represents a JSON object name only; for example: "realm/groups".
* Use double quotes with the namespace-qualified claim names.
* This property can be used if a token has no `groups` claim but has the groups set in one or more different claims.
*/
@ConfigItem
public Optional> roleClaimPath = Optional.empty();
/**
* The separator for splitting strings that contain multiple group values.
* It is only used if the "role-claim-path" property points to one or more custom claims whose values are strings.
* A single space is used by default because the standard `scope` claim can contain a space-separated sequence.
*/
@ConfigItem
public Optional roleClaimSeparator = Optional.empty();
/**
* Source of the principal roles.
*/
@ConfigItem
public Optional