Class OpenIdProvider
java.lang.Object
io.goobi.viewer.model.security.authentication.HttpAuthenticationProvider
io.goobi.viewer.model.security.authentication.OpenIdProvider
- All Implemented Interfaces:
IAuthenticationProvider
Authentication provider that authenticates users via an OpenID Connect identity provider.
-
Field Summary
FieldsFields inherited from class io.goobi.viewer.model.security.authentication.HttpAuthenticationProvider
addUserToGroups, connectionManager, DEFAULT_EMAIL, image, label, name, redirectUrl, timeoutMillis, type, TYPE_USER_PASSWORD, url -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanallowsEmailChange.booleanallowsNicknameChange.booleanChecks whether this authentication service allows user to edit their password or to reset it.completeLogin(com.auth0.jwt.interfaces.DecodedJWT jwt, HttpServletRequest request, HttpServletResponse response) Tries to find or create a validUserbased on the given json object.Getter for the fieldclientId.Getter for the fieldclientSecret.Getter for the fieldoAuthAccessToken.Getter for the fieldoAuthState.getScope()longReturns a future containing the login result upon completion.voidlogout()Logs the user out.setDiscoveryUri(String discoveryUri) setJwksUri(String jwksUri) voidsetoAuthAccessToken(String oAuthAccessToken) Setter for the fieldoAuthAccessToken.voidsetoAuthState(String oAuthState) Setter for the fieldoAuthState.setRedirectionEndpoint(String redirectionEndpoint) setResponseMode(String responseMode) setResponseType(String responseType) setThirdPartyVariables(String thirdPartyLoginUrl, String thirdPartyLoginApiKey, String thirdPartyLoginScope, String thirdPartyLoginReqParamDef, String thirdPartyLoginClaim) setTokenCheckDelay(long tokenCheckDelay) setTokenEndpoint(String tokenEndpoint) Methods inherited from class io.goobi.viewer.model.security.authentication.HttpAuthenticationProvider
get, getAddUserToGroups, getImage, getImageUrl, getLabel, getName, getRedirectUrl, getTimeoutMillis, getType, getUrl, post, setAddUserToGroups, setRedirectUrl
-
Field Details
-
TYPE_OPENID
ConstantTYPE_OPENID="openId".- See Also:
-
-
Constructor Details
-
OpenIdProvider
public OpenIdProvider(String name, String label, String url, String image, long timeoutMillis, String clientId, String clientSecret) Creates a new OpenIdProvider instance.- Parameters:
name- unique internal name identifying this providerlabel- display label shown in the UIurl- authorization endpoint URL of the providerimage- URL or path to the provider's logo imagetimeoutMillis- login response wait timeout in millisecondsclientId- OAuth client ID registered with the providerclientSecret- OAuth client secret for token exchange
-
-
Method Details
-
login
public CompletableFuture<LoginResult> login(String loginName, String password) throws AuthenticationProviderException Returns a future containing the login result upon completion. The result optionally contains the logged inUseras well as theHttpServletRequestandHttpServletResponseto be used to complete the login and possible request forwarding If an error occurs and the request can not be processed, anAuthenticationExceptionmust be thrown. If a login has been refused, the exact reasons can be determined using the methodsUser.isActive(),User.isSuspended()andLoginResult.isRefused()- Parameters:
loginName- login name or identifier supplied by the userpassword- A string to be used as a password or similar for login. If the provider does not require such a string, this can be left empty or null- Returns:
- A
CompletableFuturewhich is resolved once login is completed and contains aLoginResult - Throws:
AuthenticationProviderException- if any.
-
completeLogin
public Future<Boolean> completeLogin(com.auth0.jwt.interfaces.DecodedJWT jwt, HttpServletRequest request, HttpServletResponse response) Tries to find or create a validUserbased on the given json object. Generates aLoginResultcontaining the given request and response and either an optional containing the user or nothing if no user was found, or aAuthenticationProviderExceptionif an internal error occurred during login If this method is not called withinHttpAuthenticationProvider.getTimeoutMillis()ms after callinglogin(String, String), a loginResponse is created containing an appropriate exception. In any case, the future returned bylogin(String, String)is resolved.- Parameters:
jwt- decoded JWT token received from the OAuth callbackrequest- incoming HTTP request from the OAuth redirectresponse- HTTP response for the OAuth callback- Returns:
- a Future resolving to true if login succeeded, false otherwise
-
logout
Logs the user out.- Throws:
AuthenticationProviderException- if any.
-
allowsPasswordChange
public boolean allowsPasswordChange()Checks whether this authentication service allows user to edit their password or to reset it.- Returns:
- true if the authentication service provides means to change or reset the user password
-
allowsNicknameChange
public boolean allowsNicknameChange()allowsNicknameChange.- Returns:
- true if the nickname may be changed and is not essential for user identification
-
allowsEmailChange
public boolean allowsEmailChange()allowsEmailChange.- Returns:
- true if the email may be changed and is not essential for user identification
-
getDiscoveryUri
-
setDiscoveryUri
- Parameters:
discoveryUri- the OpenID Connect discovery endpoint URI used to retrieve provider metadata- Returns:
- this
-
getClientId
Getter for the fieldclientId.- Returns:
- the OAuth 2.0 client identifier registered with the OpenID provider
-
getClientSecret
Getter for the fieldclientSecret.- Returns:
- the OAuth 2.0 client secret used to authenticate with the OpenID provider
-
getTokenEndpoint
-
setTokenEndpoint
- Parameters:
tokenEndpoint- the URL of the token endpoint used to exchange authorization codes for tokens- Returns:
- this
-
getJwksUri
-
setJwksUri
- Parameters:
jwksUri- the URL of the JSON Web Key Set endpoint used to retrieve signing keys- Returns:
- this
-
getRedirectionEndpoint
-
setRedirectionEndpoint
- Parameters:
redirectionEndpoint- the redirect URI registered with the provider to receive the authorization response- Returns:
- this
-
getScope
-
setScope
- Parameters:
scope- the space-separated OAuth 2.0 scope values requested during authorization- Returns:
- this
-
getResponseType
-
setResponseType
- Parameters:
responseType- the OAuth 2.0 response type requested (e.g. "code" for authorization code flow)- Returns:
- this
-
getResponseMode
-
setResponseMode
- Parameters:
responseMode- the OAuth 2.0 response mode specifying how the authorization response is returned (e.g. "query", "fragment")- Returns:
- this
-
getIssuer
-
setIssuer
- Parameters:
issuer- the expected issuer claim value used to validate ID tokens from this provider- Returns:
- this
-
getTokenCheckDelay
public long getTokenCheckDelay() -
setTokenCheckDelay
- Parameters:
tokenCheckDelay- the delay in milliseconds before performing the token validation check- Returns:
- this
-
getThirdPartyLoginUrl
-
getThirdPartyLoginApiKey
-
getThirdPartyLoginScope
-
getThirdPartyLoginReqParamDef
-
getThirdPartyLoginClaim
-
setThirdPartyVariables
-
getoAuthState
Getter for the fieldoAuthState.- Returns:
- the OAuth 2.0 state parameter used to prevent cross-site request forgery
-
setoAuthState
Setter for the fieldoAuthState.- Parameters:
oAuthState- the OAuth 2.0 state parameter used to prevent cross-site request forgery
-
getoAuthAccessToken
Getter for the fieldoAuthAccessToken.- Returns:
- the OAuth 2.0 access token received from the provider
-
setoAuthAccessToken
Setter for the fieldoAuthAccessToken.- Parameters:
oAuthAccessToken- the OAuth 2.0 access token received from the provider
-