Class OpenIdAuthenticator
- All Implemented Interfaces:
Authenticator
Implements authentication using OpenId Connect on top of OAuth 2.0.
The OpenIdAuthenticator redirects unauthenticated requests to the OpenID Connect Provider. The End-User is
eventually redirected back with an Authorization Code to the path set by setRedirectPath(String)
within the context.
The Authorization Code is then used to authenticate the user through the OpenIdCredentials
and OpenIdLoginService
.
Once a user is authenticated the OpenID Claims can be retrieved through an attribute on the session with the key CLAIMS
.
The full response containing the OAuth 2.0 Access Token can be obtained with the session attribute RESPONSE
.
SessionAuthentication
is then used to wrap Authentication results so that they are associated with the session.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.security.authentication.LoginAuthenticator
LoginAuthenticator.LoggedOutAuthentication, LoginAuthenticator.UserAuthenticationSent, LoginAuthenticator.UserAuthenticationSucceeded
Nested classes/interfaces inherited from interface org.eclipse.jetty.security.Authenticator
Authenticator.Configuration, Authenticator.Factory, Authenticator.NoOp
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
Deprecated.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
Fields inherited from class org.eclipse.jetty.security.authentication.LoginAuthenticator
_identityService, _loginService
Fields inherited from interface org.eclipse.jetty.security.Authenticator
BASIC_AUTH, CERT_AUTH, CERT_AUTH2, DIGEST_AUTH, FORM_AUTH, NEGOTIATE_AUTH, OPENID_AUTH, SPNEGO_AUTH
-
Constructor Summary
ConstructorDescriptionOpenIdAuthenticator
(OpenIdConfiguration configuration) OpenIdAuthenticator
(OpenIdConfiguration configuration, String errorPage) OpenIdAuthenticator
(OpenIdConfiguration configuration, String redirectPath, String errorPage) OpenIdAuthenticator
(OpenIdConfiguration configuration, String redirectPath, String errorPage, String logoutRedirectPath) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
getChallengeUri
(Request request) getConstraintAuthentication
(String pathInContext, Constraint.Authorization existing, Function<Boolean, Session> getSession) Get anConstraint.Authorization
applicable to the path for this authenticator.protected Fields
getParameters
(Request request) boolean
Deprecated.boolean
isErrorPage
(String pathInContext) boolean
isJSecurityCheck
(String uri) If the UserIdentity returned fromLoginService.login(String, Object, Request, Function)
is not null, it is assumed that the user is fully authenticated and we need to change the session id to prevent session fixation vulnerability.void
prepareRequest
(Request request, AuthenticationState authenticationState) Called afterAuthenticator.validateRequest(Request, Response, Callback)
and before callingRequest.Handler.handle(Request, Response, Callback)
of the nested handler.void
setAlwaysSaveUri
(boolean alwaysSave) Deprecated.void
setConfiguration
(Authenticator.Configuration authConfig) Configure the Authenticatorvoid
setErrorPage
(String path) void
setLogoutRedirectPath
(String logoutRedirectPath) void
setRedirectPath
(String redirectPath) validateRequest
(Request request, Response response, Callback cb) Validate a requestMethods inherited from class org.eclipse.jetty.security.authentication.LoginAuthenticator
getLoginService, updateSession
-
Field Details
-
CLAIMS
- See Also:
-
RESPONSE
- See Also:
-
ISSUER
- See Also:
-
REDIRECT_PATH
- See Also:
-
LOGOUT_REDIRECT_PATH
- See Also:
-
ERROR_PAGE
- See Also:
-
J_URI
- See Also:
-
J_POST
- See Also:
-
J_METHOD
- See Also:
-
J_SECURITY_CHECK
- See Also:
-
ERROR_PARAMETER
- See Also:
-
CSRF_TOKEN
Deprecated.- See Also:
-
-
Constructor Details
-
OpenIdAuthenticator
public OpenIdAuthenticator() -
OpenIdAuthenticator
-
OpenIdAuthenticator
-
OpenIdAuthenticator
public OpenIdAuthenticator(OpenIdConfiguration configuration, String redirectPath, String errorPage) -
OpenIdAuthenticator
public OpenIdAuthenticator(OpenIdConfiguration configuration, String redirectPath, String errorPage, String logoutRedirectPath)
-
-
Method Details
-
setConfiguration
Description copied from interface:Authenticator
Configure the Authenticator- Specified by:
setConfiguration
in interfaceAuthenticator
- Overrides:
setConfiguration
in classLoginAuthenticator
- Parameters:
authConfig
- the configuration
-
getAuthenticationType
- Returns:
- The name of the authentication type
-
setAlwaysSaveUri
Deprecated. -
isAlwaysSaveUri
Deprecated. -
setRedirectPath
-
setLogoutRedirectPath
-
setErrorPage
-
login
Description copied from class:LoginAuthenticator
If the UserIdentity returned fromLoginService.login(String, Object, Request, Function)
is not null, it is assumed that the user is fully authenticated and we need to change the session id to prevent session fixation vulnerability. If the UserIdentity is not necessarily fully authenticated, then subclasses must override this method and determine when the UserIdentity IS fully authenticated and renew the session id.- Overrides:
login
in classLoginAuthenticator
- Parameters:
username
- the username of the client to be authenticatedcredentials
- the user's credentialrequest
- the inbound request that needs authentication
-
logout
- Overrides:
logout
in classLoginAuthenticator
-
prepareRequest
Description copied from interface:Authenticator
Called afterAuthenticator.validateRequest(Request, Response, Callback)
and before callingRequest.Handler.handle(Request, Response, Callback)
of the nested handler. This may be used by anAuthenticator
to restore method or content from a previous request that was challenged.- Parameters:
request
- the request to prepare for handlingauthenticationState
- The authentication for the request
-
getParameters
-
getConstraintAuthentication
public Constraint.Authorization getConstraintAuthentication(String pathInContext, Constraint.Authorization existing, Function<Boolean, Session> getSession) Description copied from interface:Authenticator
Get anConstraint.Authorization
applicable to the path for this authenticator. This is typically used to vary protection on special URIs known to a specificAuthenticator
(e.g. /j_security_check for theFormAuthenticator
.- Parameters:
pathInContext
- The pathInContext to potentially constrain.existing
- The existing authentication constraint for the pathInContext determined independently ofAuthenticator
getSession
- Function to get or create aSession
.- Returns:
- The
Constraint.Authorization
to apply.
-
validateRequest
public AuthenticationState validateRequest(Request request, Response response, Callback cb) throws ServerAuthException Description copied from interface:Authenticator
Validate a request- Parameters:
request
- The requestresponse
- The responsecb
- the callback to use for writing a response- Returns:
- An Authentication. If Authentication is successful, this will be a
AuthenticationState.Succeeded
. If a response has been sent by the Authenticator (which can be done for both successful and unsuccessful authentications), then the result will implementAuthenticationState.ResponseSent
. - Throws:
ServerAuthException
- if unable to validate request
-
isJSecurityCheck
-
isErrorPage
-
getChallengeUri
-