Class OidcConfig
java.lang.Object
io.helidon.security.providers.oidc.common.OidcConfig
- All Implemented Interfaces:
TenantConfig
Configuration of OIDC usable from all resources that utilize OIDC specification, such as security provider, web server
extension and IDCS connectivity.
Some of the configuration options below use "resource" type. The following configuration
can be used for a resource (example for oidc-metadata key):
oidc-metadata-path: "path/on/filesystem"
oidc-metadata-resource-path: "class-path/resource"
oidc-metadata-url: "URI on the net"
oidc-metadata-content-plain: "Value of the resource in plain text"
oidc-metadata-content: "Value in base64 encoded bytes"
Configuration options required (under security.providers[].${name}):
| key | description |
|---|---|
| client-id | Client ID as generated by OIDC server |
| client-secret | Client secret as generated by OIDC server |
| identity-uri | URI of the identity server, base used to retrieve OIDC metadata |
| frontend-uri | Full URI of the frontend for redirects back from OIDC server (e.g. http://myserver/myApp) |
| key | default value | description |
|---|---|---|
| proxy-protocol | http | Proxy protocol to use when proxy is used. |
| proxy-host | null | Proxy host to use. When defined, triggers usage of proxy for HTTP requests. |
| proxy-port | 80 | Port of the proxy server to use |
| relative-uris | false | Flag to force the use of relative URIs in all requests. By default, requests that use the Proxy will have absolute URIs. Set this flag to true if the host is unable to accept absolute URIs. |
| redirect-uri | /oidc/redirect | URI to register web server component on, used by the OIDC server to redirect authorization requests to after a user logs in or approves scopes. Note that usually the redirect URI configured here must be the same one as configured on OIDC server. |
| scope-audience | empty string | Audience of the scope required by this application. This is prefixed to the scope name when requesting scopes from the identity server. |
| cookie-use | true | Whether to use cookie to store JWT. If used, redirects happen only in case the user is not authenticated or has insufficient scopes |
| cookie-name | JSESSIONID | Name of the cookie |
| cookie-domain | null | Domain the cookie is valid for. Not used by default |
| cookie-path | / | Path the cookie is valid for. |
| cookie-max-age-seconds | null | When using cookie, used to set MaxAge attribute of the cookie, defining how long the cookie is valid. |
| cookie-http-only | true | When using cookie, if set to true, the HttpOnly attribute will be configured. |
| cookie-secure | false | When using cookie, if set to true, the Secure attribute will be configured. |
| cookie-same-site | Lax | When using cookie, used to set the SameSite cookie value. Can be "Strict" or "Lax". Setting this to "Strict" will result in infinite redirects when calling OIDC on a different host. |
| query-param-use | false | Whether to expect JWT in a query parameter |
| query-param-name | accessToken | Name of a query parameter that contains the JWT token when parameter is used. |
| header-use | true | Whether to expect JWT in a header field. |
| header-token | "Authorization" header with prefix "bearer " | A TokenHandler configuration to process header containing a JWT |
| oidc-metadata-well-known | true | If set to true, metadata will be loaded from default (well known) location, unless it is explicitly defined using oidc-metadata-resource. If set to false, it would not be loaded even if oidc-metadata-resource is not defined. In such a case all URIs must be explicitly defined (e.g. token-endpoint-uri). |
| oidc-metadata.resource | identity-uri/.well-known/openid-configuration | Resource configuration for OIDC Metadata containing endpoints to various identity services, as well as information
about the identity server. See Resource.create(io.helidon.common.config.Config) |
| token-endpoint-uri | token_endpoint in OIDC metadata, or identity-url/oauth2/v1/token if not available | URI of a token endpoint used to obtain a JWT based on the authentication code. |
| authorization-endpoint-uri | "authorization_endpoint" in OIDC metadata, or identity-uri/oauth2/v1/authorize if not available | URI of an authorization endpoint used to redirect users to for logging-in. |
| validate-with-jwk | true | When true - validate against jwk defined by "sign-jwk", when false validate JWT through OIDC Server endpoint "validation-endpoint-uri" |
| sign-jwk.resource | "jwks-uri" in OIDC metadata, or identity-uri/admin/v1/SigningCert/jwk if not available, only needed when jwt validation is done by us | A resource pointing to JWK with public keys of signing certificates used to validate JWT.
See Resource.create(io.helidon.common.config.Config) |
| introspect-endpoint-uri | "introspection_endpoint" in OIDC metadata, or identity-uri/oauth2/v1/introspect | When validate-with-jwk is set to "false", this is the endpoint used |
| base-scopes | "openid"<B extends io.helidon.security.providers.oidc.common.BaseBuilder<B, |
Configure scopes to be requested by default. If the scope has a qualifier, it must be included here |
| redirect | false | Whether to redirect to identity server when authentication failed. |
| realm | helidon | Realm returned in HTTP response if redirect is not enabled or possible. |
| redirect-attempt-param | "h_ra" | Query parameter holding the number of times we redirected to an identity server. Customizable to prevent conflicts with application parameters |
| max-redirects | 5 | Maximal number of times we can redirect to an identity server. When the number is reached, no further redirects
happen and the request finishes with an error (status 401) |
| server-type | Type of identity server. Currently supported is idcs or not configured (for default). |
|
client-timeout-millis |
30 seconds | Timeout on HTTP client calls |
cookie-encryption-enabled |
Depends on other configuration | Whether cookies should be encrypted. Will be enabled if logout is enabled. |
cookie-encryption-password |
Generated for this service (as a file) | Encryption password to be used for symmetric cipher. Must be the same for all services that are intended to share a cookie as a form of authentication |
cookie-encryption-name |
Name of encryption configuration in Security. If used, security must be registered
in curent context or in global context (this is done automatically in Helidon MP). |
|
logout-endpoint-uri |
From well known metadata endpoint | Endpoint to redirect user to log out from OIDC server. |
post-logout-uri |
Required if logout is enabled. Endpoint the OIDC server redirects back to after logging user out. | |
logout-enabled |
false |
Whether logout support should be enabled. Requires encryption of cookies (and cookies must be used). |
cors |
Cross-origin resource sharing settings. See CrossOriginConfig. |
|
force-https-redirects |
Force https for redirects to identity provider. This is helpful if you have a frontend SSL or cloud load balancer in front and Helidon is serving plain http. | |
optional-audience |
false |
Allow audience claim to be optional. |
check-audience |
true |
Turn audience claim check on when true or off when false. |
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classA fluent APIBuilderto build instances ofOidcConfig.static enumClient Authentication methods that are used by Clients to authenticate to the Authorization Server when using the Token Endpoint.static enumTypes of requests to identity provider. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDefault access token cookie name.static final StringDefault id token cookie name.static final StringDefault refresh token cookie name.static final StringDefault state cookie name.static final StringDefault tenant cookie name.static final StringDefault tenant query param name.static final StringDefault name of the header we expect JWT in.static final StringDefault name of the header we expect JWT in. -
Method Summary
Modifier and TypeMethodDescriptionClient with configured proxy and security.audience()Expected token audience.Authorization endpoint.Authorization endpoint.Base scopes to require from OIDC server.static OidcConfig.Builderbuilder()Create a builder to programmatically construct OIDC configuration.booleanWhether to validate audience token.clientId()Client id of this client.Client secret.Expected timeout of HTTP client operations.static OidcConfigCreate a new instance fromConfig.Cross-origin resource sharing settings.booleanWhether to force https when redirecting to identity provider.Client with configured proxy with no security.TokenHandlerto extract header information from request.Identity server URI.Cookie handler to create cookies or unset cookies for id token.Query id token parameter name.booleanWhether id token signature should be validated.Introspection endpoint URI.issuer()Token issuer.booleanWhether logout is enabled.Logout endpoint on OIDC server.Logout URI.intMaximal number of redirects allowed between Helidon and OIDC provider.name()Name of the tenant.OIDC metadata.Query parameter name.Post logout redirect URI.realm()Realm to use for WWW-Authenticate response (if needed).Name of the parameter used in state passed to OIDC to store the number of attempted redirects.Redirection URI.Redirect URI with host information.redirectUriWithHost(String frontendUri) Redirect URI with host information taken from request, unless an explicit frontend uri is defined in configuration.Cookie handler to create cookies or unset cookies for refresh token.booleanDetermines whether to force the use of relative URIs in all requests, regardless of the presence or absence of proxies or no-proxy lists.Audience URI of custom scopes.Server type.booleanWhether to redirect to identity server if user is not authenticated.signJwk()JWK used for signature validation.Cookie handler to create cookies or unset cookies for state value.tenantConfig(String tenantId) ReturnTenantConfigbound to the provided tenant id.Cookie handler to create cookies or unset cookies for tenant name.Introspection endpoint URI.Return provided token issuer.Logout endpoint on OIDC server.Tenant query parameter name.JWK used for signature validation.Token endpoint URI.Cookie handler to create cookies or unset cookies for token.Type of authentication mechanism used for token endpoint.Token endpoint URI.Amount of time access token should be refreshed before its expiration time.booleanWhether access token signature should be validated.booleanWhether to use cooke to get the information from request.booleanWhether to use HTTP header to get the information from request.booleanuseParam()Whether to use query parameter to get the information from request.booleanWhether to use OIDC well known metadata.booleanWhether to validate JWT with JWK information (e.g.
-
Field Details
-
PARAM_HEADER_NAME
Default name of the header we expect JWT in.- See Also:
-
PARAM_ID_HEADER_NAME
Default name of the header we expect JWT in.- See Also:
-
DEFAULT_TENANT_PARAM_NAME
Default tenant query param name.- See Also:
-
DEFAULT_COOKIE_NAME
Default access token cookie name.- See Also:
-
DEFAULT_ID_COOKIE_NAME
Default id token cookie name.- See Also:
-
DEFAULT_REFRESH_COOKIE_NAME
Default refresh token cookie name.- See Also:
-
DEFAULT_TENANT_COOKIE_NAME
Default tenant cookie name.- See Also:
-
DEFAULT_STATE_COOKIE_NAME
Default state cookie name.- See Also:
-
-
Method Details
-
builder
Create a builder to programmatically construct OIDC configuration.- Returns:
- a new builder instance usable for fluent API
-
create
Create a new instance fromConfig. The config instance has to be on the node containing keys used by this class (e.g. client-id).- Parameters:
config- configuration used to obtain OIDC integration values- Returns:
- a new instance of this class configured from provided config
-
useParam
public boolean useParam()Whether to use query parameter to get the information from request.- Returns:
- if query parameter should be used
- See Also:
-
paramName
Query parameter name.- Returns:
- name of the query parameter to use
- See Also:
-
idTokenParamName
Query id token parameter name.- Returns:
- name of the query parameter to use
- See Also:
-
tenantParamName
Tenant query parameter name.- Returns:
- name of the tenant query parameter to use
- See Also:
-
useHeader
public boolean useHeader()Whether to use HTTP header to get the information from request.- Returns:
- if header should be used
- See Also:
-
headerHandler
TokenHandlerto extract header information from request.- Returns:
- handler to extract header
- See Also:
-
useCookie
public boolean useCookie()Whether to use cooke to get the information from request.- Returns:
- if cookie should be used
- See Also:
-
tokenCookieHandler
Cookie handler to create cookies or unset cookies for token.- Returns:
- a new cookie handler
-
idTokenCookieHandler
Cookie handler to create cookies or unset cookies for id token.- Returns:
- a new cookie handler
-
tenantCookieHandler
Cookie handler to create cookies or unset cookies for tenant name.- Returns:
- a new cookie handler
-
refreshTokenCookieHandler
Cookie handler to create cookies or unset cookies for refresh token.- Returns:
- a new cookie handler
-
stateCookieHandler
Cookie handler to create cookies or unset cookies for state value.- Returns:
- a new cookie handler
-
redirectUri
Redirection URI.- Returns:
- uri the OIDC server redirects back to
- See Also:
-
forceHttpsRedirects
public boolean forceHttpsRedirects()Whether to force https when redirecting to identity provider.- Returns:
trueto force use of https
-
logoutEnabled
public boolean logoutEnabled()Whether logout is enabled.- Returns:
trueif logout is enabled
-
logoutUri
Logout URI.- Returns:
- uri that processes logout in Helidon and redirects to OIDC server logout
- See Also:
-
postLogoutUri
Post logout redirect URI.- Returns:
- uri that OIDC server redirects to once logout is finished
- See Also:
-
redirectUriWithHost
Redirect URI with host information.- Returns:
- redirect URI
- See Also:
-
redirectUriWithHost
Redirect URI with host information taken from request, unless an explicit frontend uri is defined in configuration.- Parameters:
frontendUri- the frontend uri- Returns:
- redirect URI
-
shouldRedirect
public boolean shouldRedirect()Whether to redirect to identity server if user is not authenticated.- Returns:
- whether to redirect, defaults to true
-
redirectAttemptParam
Name of the parameter used in state passed to OIDC to store the number of attempted redirects. This is to prevent infinite redirects.- Returns:
- name of the query parameter
-
maxRedirects
public int maxRedirects()Maximal number of redirects allowed between Helidon and OIDC provider.- Returns:
- maximal number of redirects
-
crossOriginConfig
Cross-origin resource sharing settings.- Returns:
- CORS settings
-
tokenRefreshSkew
Amount of time access token should be refreshed before its expiration time.- Returns:
- refresh time skew
-
relativeUris
public boolean relativeUris()Determines whether to force the use of relative URIs in all requests, regardless of the presence or absence of proxies or no-proxy lists.- Returns:
trueif we should use relative URIs
-
generalWebClient
Client with configured proxy with no security.- Returns:
- client for general use.
-
appWebClient
Client with configured proxy and security.- Returns:
- client for communicating with OIDC identity server
-
tenantConfig
ReturnTenantConfigbound to the provided tenant id. If noTenantConfigfound, default OIDC configuration should be returned.- Parameters:
tenantId- tenant id of the configuration- Returns:
- configuration bound to the tenant id, or default oidc configuration if not found
-
tokenEndpointUri
Token endpoint URI.- Returns:
- endpoint URI
-
authorizationEndpointUri
Authorization endpoint.- Returns:
- authorization endpoint uri as a string
-
logoutEndpointUri
Logout endpoint on OIDC server.- Returns:
- URI of the logout endpoint
- See Also:
-
issuer
Token issuer.- Returns:
- token issuer
- See Also:
-
signJwk
JWK used for signature validation.- Returns:
- set of keys used use to verify tokens
-
introspectUri
Introspection endpoint URI.- Returns:
- introspection endpoint URI
- See Also:
-
tokenSignatureValidation
public boolean tokenSignatureValidation()Whether access token signature should be validated.- Returns:
- validate access token signature
-
idTokenSignatureValidation
public boolean idTokenSignatureValidation()Whether id token signature should be validated.- Returns:
- validate id token signature
-
tenantSignJwk
Description copied from interface:TenantConfigJWK used for signature validation. Empty if no jwk has been provided via configuration.- Specified by:
tenantSignJwkin interfaceTenantConfig- Returns:
- set of keys used to verify tokens
-
tenantLogoutEndpointUri
Description copied from interface:TenantConfigLogout endpoint on OIDC server. Empty if no logout endpoint uri has been provided via configuration.- Specified by:
tenantLogoutEndpointUriin interfaceTenantConfig- Returns:
- URI of the logout endpoint
-
tenantTokenEndpointUri
Description copied from interface:TenantConfigToken endpoint URI. Empty if no token endpoint uri has been provided via configuration.- Specified by:
tenantTokenEndpointUriin interfaceTenantConfig- Returns:
- endpoint URI
-
clientId
Description copied from interface:TenantConfigClient id of this client.- Specified by:
clientIdin interfaceTenantConfig- Returns:
- client id
-
name
Description copied from interface:TenantConfigName of the tenant.- Specified by:
namein interfaceTenantConfig- Returns:
- tenant name
-
baseScopes
Description copied from interface:TenantConfigBase scopes to require from OIDC server.- Specified by:
baseScopesin interfaceTenantConfig- Returns:
- base scopes
-
validateJwtWithJwk
public boolean validateJwtWithJwk()Description copied from interface:TenantConfigWhether to validate JWT with JWK information (e.g. verify signatures locally).- Specified by:
validateJwtWithJwkin interfaceTenantConfig- Returns:
- if we should validate JWT with JWK
-
tenantIntrospectUri
Description copied from interface:TenantConfigIntrospection endpoint URI. Empty if no introspection endpoint has been provided via configuration.- Specified by:
tenantIntrospectUriin interfaceTenantConfig- Returns:
- introspection endpoint URI
-
tenantIssuer
Description copied from interface:TenantConfigReturn provided token issuer. Empty if no issuer has been provided via configuration.- Specified by:
tenantIssuerin interfaceTenantConfig- Returns:
- token issuer
-
audience
Description copied from interface:TenantConfigExpected token audience.- Specified by:
audiencein interfaceTenantConfig- Returns:
- audience
-
checkAudience
public boolean checkAudience()Description copied from interface:TenantConfigWhether to validate audience token.- Specified by:
checkAudiencein interfaceTenantConfig- Returns:
- audience
-
scopeAudience
Description copied from interface:TenantConfigAudience URI of custom scopes.- Specified by:
scopeAudiencein interfaceTenantConfig- Returns:
- scope audience
-
identityUri
Description copied from interface:TenantConfigIdentity server URI.- Specified by:
identityUriin interfaceTenantConfig- Returns:
- identity server URI
-
realm
Description copied from interface:TenantConfigRealm to use for WWW-Authenticate response (if needed).- Specified by:
realmin interfaceTenantConfig- Returns:
- realm name
-
tokenEndpointAuthentication
Description copied from interface:TenantConfigType of authentication mechanism used for token endpoint.- Specified by:
tokenEndpointAuthenticationin interfaceTenantConfig- Returns:
- client authentication type
-
clientTimeout
Description copied from interface:TenantConfigExpected timeout of HTTP client operations.- Specified by:
clientTimeoutin interfaceTenantConfig- Returns:
- client timeout
-
authorizationEndpoint
Description copied from interface:TenantConfigAuthorization endpoint.- Specified by:
authorizationEndpointin interfaceTenantConfig- Returns:
- authorization endpoint uri as a string
-
clientSecret
Description copied from interface:TenantConfigClient secret.- Specified by:
clientSecretin interfaceTenantConfig- Returns:
- configured client secret
-
serverType
Description copied from interface:TenantConfigServer type.- Specified by:
serverTypein interfaceTenantConfig- Returns:
- configured server type
-
oidcMetadata
Description copied from interface:TenantConfigOIDC metadata.- Specified by:
oidcMetadatain interfaceTenantConfig- Returns:
- configured oidc metadata
-
useWellKnown
public boolean useWellKnown()Description copied from interface:TenantConfigWhether to use OIDC well known metadata.- Specified by:
useWellKnownin interfaceTenantConfig- Returns:
- configured oidc metadata
-