Package io.vertx.ext.web.handler
Interface SimpleAuthenticationHandler
-
- All Superinterfaces:
AuthenticationHandler
,Handler<RoutingContext>
public interface SimpleAuthenticationHandler extends AuthenticationHandler
A user customizable authentication handler.An auth handler allows your application to provide authentication support. The handler is not fully functional without a authentication function. This function takes the
RoutingContext
as input and returns aFuture
. The future should return a nonnull
user object. In theauthenticate(Function)
you have full control on the request, so all operations like redirect, next, fail are allowed. There are some rules that need to be followed in order to allow this handler to properly interop withChainAuthHandler
.- Author:
- Paulo Lopes
-
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description SimpleAuthenticationHandler
authenticate(java.util.function.Function<RoutingContext,Future<User>> authenticationFunction)
This function will allow you to perform authentication the way you intended to.static SimpleAuthenticationHandler
create()
Creates a new instance of the simple authentication handler.
-
-
-
Method Detail
-
create
static SimpleAuthenticationHandler create()
Creates a new instance of the simple authentication handler.- Returns:
- a new instance.
-
authenticate
SimpleAuthenticationHandler authenticate(java.util.function.Function<RoutingContext,Future<User>> authenticationFunction)
This function will allow you to perform authentication the way you intended to. The process should be self explanatory, for example if the request contains a given property completing the function with a nonnull
User
object is enough to allow the handler to continue. In order to signal errors, you should not callRoutingContext.fail(int)
orRoutingContext.fail(Throwable)
. Errors should be signaled using theHttpException
type. Any other kind of errors will be wrapped as a 401 error. For example forbidden access should be signaled with:new HttpException(403)
. This is required when working withChainAuthHandler
. By using exceptions to signal failures instead of immediately terminating the request, it allows the chain to proceed to the next handler if needed.- Parameters:
authenticationFunction
- the authentication function.- Returns:
- self
-
-