public interface AuthService
Handles authentication and role/permission based authorisation.
Modifier and Type | Field and Description |
---|---|
static long |
DEFAULT_LOGIN_TIMEOUT
How long in ms, by default, a login will remain valid for before being expired
|
static long |
DEFAULT_REAPER_PERIOD
How long, in ms, to check for expired logins and remove them.
|
Modifier and Type | Method and Description |
---|---|
static AuthService |
create(Vertx vertx,
AuthProvider provider)
Create an auth service instance using the specified auth provider instance.
|
static AuthService |
createEventBusProxy(Vertx vertx,
String address)
Create a proxy to an auth service that is deployed somwehere on the event bus.
|
static AuthService |
createFromClassName(Vertx vertx,
String className)
Create an auth service instance using the specified auth provider class name.
|
AuthService |
hasPermission(String loginID,
String permission,
Handler<AsyncResult<Boolean>> resultHandler)
Does the user have the specified permission?
|
AuthService |
hasPermissions(String loginID,
Set<String> permissions,
Handler<AsyncResult<Boolean>> resultHandler)
Does the user have the specified permissions?
|
AuthService |
hasRole(String loginID,
String role,
Handler<AsyncResult<Boolean>> resultHandler)
Does the user have the specified role?
|
AuthService |
hasRoles(String loginID,
Set<String> roles,
Handler<AsyncResult<Boolean>> resultHandler)
Does the user have the specified roles?
|
AuthService |
login(JsonObject principal,
JsonObject credentials,
Handler<AsyncResult<String>> resultHandler)
Authenticate (login) using the specified credentials.
|
AuthService |
loginWithTimeout(JsonObject principal,
JsonObject credentials,
long timeout,
Handler<AsyncResult<String>> resultHandler)
Authenticate (login) using the specified credentials.
|
AuthService |
logout(String loginID,
Handler<AsyncResult<Void>> resultHandler)
Logout the user
|
AuthService |
refreshLoginSession(String loginID,
Handler<AsyncResult<Void>> resultHandler)
Refresh an existing login ID so it doesn't expire
|
AuthService |
setReaperPeriod(long reaperPeriod)
Set the reaper period - how often to check for expired logins, in ms.
|
void |
start()
Start the service
|
void |
stop()
Stop the service
|
static final long DEFAULT_LOGIN_TIMEOUT
static final long DEFAULT_REAPER_PERIOD
static AuthService create(Vertx vertx, AuthProvider provider)
vertx
- the Vert.x instanceprovider
- the auth providerstatic AuthService createFromClassName(Vertx vertx, String className)
vertx
- the Vert.x instanceclassName
- the fully qualified class name of the auth provider implementation classstatic AuthService createEventBusProxy(Vertx vertx, String address)
vertx
- the vert.x instanceaddress
- the address on the event bus where the auth service is listeningAuthService login(JsonObject principal, JsonObject credentials, Handler<AsyncResult<String>> resultHandler)
principal
- represents the unique id (e.g. username) of the user being logged incredentials
- the credentials - e.g. passwordresultHandler
- will be passed a failed result if login failed or will be passed a succeeded result containing
the login ID (a string) if login was successful.AuthService loginWithTimeout(JsonObject principal, JsonObject credentials, long timeout, Handler<AsyncResult<String>> resultHandler)
principal
- represents the unique id (e.g. username) of the user being logged incredentials
- the credentialstimeout
- the login timeout to use, in msresultHandler
- will be passed a failed result if login failed or will be passed a succeeded result containing
the login ID (a string) if login was successful.AuthService logout(String loginID, Handler<AsyncResult<Void>> resultHandler)
loginID
- the login ID as provided by login(io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
.resultHandler
- will be called with success or failureAuthService refreshLoginSession(String loginID, Handler<AsyncResult<Void>> resultHandler)
loginID
- the login ID as provided by login(io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
.resultHandler
- will be called with success or failureAuthService hasRole(String loginID, String role, Handler<AsyncResult<Boolean>> resultHandler)
loginID
- the login ID as provided by login(io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
.role
- the roleresultHandler
- will be called with the result - true if has role, false if notAuthService hasRoles(String loginID, Set<String> roles, Handler<AsyncResult<Boolean>> resultHandler)
loginID
- the login ID as provided by login(io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
.roles
- the set of rolesresultHandler
- will be called with the result - true if has roles, false if notAuthService hasPermission(String loginID, String permission, Handler<AsyncResult<Boolean>> resultHandler)
loginID
- the login ID as provided by login(io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
.permission
- the permissionresultHandler
- will be called with the result - true if has permission, false if notAuthService hasPermissions(String loginID, Set<String> permissions, Handler<AsyncResult<Boolean>> resultHandler)
loginID
- the login ID as provided by login(io.vertx.core.json.JsonObject, io.vertx.core.json.JsonObject, io.vertx.core.Handler<io.vertx.core.AsyncResult<java.lang.String>>)
.permissions
- the set of permissionsresultHandler
- will be called with the result - true if has permissions, false if notAuthService setReaperPeriod(long reaperPeriod)
reaperPeriod
- the reaper period, in msvoid start()
void stop()
Copyright © 2015. All Rights Reserved.