U
- The UserProfile
typepublic interface Authorizer<U extends UserProfile>
In particular, this allows control over which requests require authentication, the mechanism for performing access control, and the handling of authentication failures.
AbstractAuthorizer
Modifier and Type | Method and Description |
---|---|
void |
handleAuthenticationFailure(Context context)
Handles a failure to perform authentication.
|
void |
handleAuthorization(Context context,
U userProfile)
Handles authorization for the given context.
|
boolean |
isAuthenticationRequired(Context context)
Determines whether authentication is required for a given context.
|
boolean isAuthenticationRequired(Context context)
If this method returns true
, unauthenticated users are redirected to the identity provider.
context
- The context to handlevoid handleAuthorization(Context context, U userProfile) throws Exception
This method is only called for requests that require authentication.
If the request is properly authorized, it's sufficient to call Context.next()
.
If the request is not properly authorized, it is this method's responsibility to either return an appropriate error response, or redirect to an error page.
context
- The context to handleuserProfile
- The authenticated user profileException
- if anything goes wrong (exception will be implicitly passed to the context's ReadOnlyContext.error(Exception)
method)isAuthenticationRequired(ratpack.handling.Context)
void handleAuthenticationFailure(Context context)
This will usually involve either directly sending some form of error response, forwarding the error to the client error handler, or redirecting the user to an error page.
context
- The context to handle