public interface MongoAuth extends AuthProvider
MongoClient
as storeModifier and Type | Field and Description |
---|---|
static String |
DEFAULT_COLLECTION_NAME
The default name of the collection to be used
|
static String |
DEFAULT_CREDENTIAL_PASSWORD_FIELD
The default name of the property for the password, like it is transported in credentials by method
AuthProvider.authenticate(JsonObject, Handler) |
static String |
DEFAULT_CREDENTIAL_USERNAME_FIELD
The default name of the property for the username, like it is transported in credentials by method
AuthProvider.authenticate(JsonObject, Handler) |
static String |
DEFAULT_PASSWORD_FIELD
The default name of the property for the password, like it is stored in mongodb
|
static String |
DEFAULT_PERMISSION_FIELD
The default name of the property for the permissions, like it is stored in mongodb.
|
static String |
DEFAULT_ROLE_FIELD
The default name of the property for the roles, like it is stored in mongodb.
|
static String |
DEFAULT_SALT_FIELD
The default name of the property for the salt field
|
static String |
DEFAULT_USERNAME_FIELD
The default name of the property for the username, like it is stored in mongodb
|
static String |
PROPERTY_COLLECTION_NAME
The property name to be used to set the name of the collection inside the config
|
static String |
PROPERTY_CREDENTIAL_PASSWORD_FIELD
The property name to be used to set the name of the field, where the password for the credentials is stored inside
|
static String |
PROPERTY_CREDENTIAL_USERNAME_FIELD
The property name to be used to set the name of the field, where the username for the credentials is stored inside
|
static String |
PROPERTY_PASSWORD_FIELD
The property name to be used to set the name of the field, where the password is stored inside
|
static String |
PROPERTY_PERMISSION_FIELD
The property name to be used to set the name of the field, where the permissions are stored inside
|
static String |
PROPERTY_ROLE_FIELD
The property name to be used to set the name of the field, where the roles are stored inside
|
static String |
PROPERTY_SALT_FIELD
The property name to be used to set the name of the field, where the SALT is stored inside
|
static String |
PROPERTY_SALT_STYLE
The property name to be used to set the name of the field, where the salt style is stored inside
|
static String |
PROPERTY_USERNAME_FIELD
The property name to be used to set the name of the field, where the username is stored inside
|
static String |
ROLE_PREFIX
The prefix which is used by the method
User.isAuthorised(String, Handler) when checking for role access |
Modifier and Type | Method and Description |
---|---|
static MongoAuth |
create(MongoClient mongoClient,
JsonObject config)
Creates an instance of MongoAuth by using the given
MongoClient and configuration object. |
String |
getCollectionName()
The name of the collection used to store User objects inside.
|
HashStrategy |
getHashStrategy()
The HashStrategy which is used by the current instance
|
String |
getPasswordCredentialField()
Get the name of the field to be used as property for the password of credentials in the method
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler) . |
String |
getPasswordField()
Get the name of the field to be used for the password Defaults to
DEFAULT_PASSWORD_FIELD |
String |
getPermissionField()
Get the name of the field to be used for the permissions.
|
String |
getRoleField()
Get the name of the field to be used for the roles.
|
String |
getSaltField()
Get the name of the field to be used for the salt.
|
String |
getUsernameCredentialField()
Get the name of the field to be used as property for the username in the method
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler) . |
String |
getUsernameField()
Get the name of the field to be used for the username.
|
void |
insertUser(String username,
String password,
List<String> roles,
List<String> permissions,
Handler<AsyncResult<String>> resultHandler)
Insert a new user into mongo in the convenient way
|
MongoAuth |
setCollectionName(String collectionName)
Set the name of the collection to be used.
|
MongoAuth |
setHashAlgorithm(HashAlgorithm hashAlgorithm)
The Hash Algorithm which is used by the current instance
|
MongoAuth |
setHashStrategy(HashStrategy hashStrategy)
The HashStrategy which is used by the current instance
|
MongoAuth |
setPasswordCredentialField(String fieldName)
Set the name of the field to be used as property for the password of credentials in the method
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler) . |
MongoAuth |
setPasswordField(String fieldName)
Set the name of the field to be used for the password Defaults to
DEFAULT_PASSWORD_FIELD |
MongoAuth |
setPermissionField(String fieldName)
Set the name of the field to be used for the permissions.
|
MongoAuth |
setRoleField(String fieldName)
Set the name of the field to be used for the roles.
|
MongoAuth |
setSaltField(String fieldName)
Set the name of the field to be used for the salt.
|
MongoAuth |
setUsernameCredentialField(String fieldName)
Set the name of the field to be used as property for the username in the method
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler) . |
MongoAuth |
setUsernameField(String fieldName)
Set the name of the field to be used for the username.
|
authenticate
static final String PROPERTY_COLLECTION_NAME
static final String PROPERTY_USERNAME_FIELD
static final String PROPERTY_ROLE_FIELD
static final String PROPERTY_PERMISSION_FIELD
static final String PROPERTY_PASSWORD_FIELD
static final String PROPERTY_CREDENTIAL_USERNAME_FIELD
static final String PROPERTY_CREDENTIAL_PASSWORD_FIELD
static final String PROPERTY_SALT_FIELD
static final String PROPERTY_SALT_STYLE
HashSaltStyle
,
Constant Field Valuesstatic final String DEFAULT_COLLECTION_NAME
static final String DEFAULT_USERNAME_FIELD
static final String DEFAULT_PASSWORD_FIELD
static final String DEFAULT_ROLE_FIELD
static final String DEFAULT_PERMISSION_FIELD
static final String DEFAULT_CREDENTIAL_USERNAME_FIELD
AuthProvider.authenticate(JsonObject, Handler)
static final String DEFAULT_CREDENTIAL_PASSWORD_FIELD
AuthProvider.authenticate(JsonObject, Handler)
static final String DEFAULT_SALT_FIELD
static final String ROLE_PREFIX
User.isAuthorised(String, Handler)
when checking for role accessstatic MongoAuth create(MongoClient mongoClient, JsonObject config)
MongoClient
and configuration object. An example for a
configuration object:
JsonObject js = new JsonObject(); js.put(MongoAuth.PROPERTY_COLLECTION_NAME, createCollectionName(MongoAuth.DEFAULT_COLLECTION_NAME));
mongoClient
- an instance of MongoClient
to be used for data storage and retrivalconfig
- the configuration object for the current instance. By thisMongoAuth
sMongoAuth setCollectionName(String collectionName)
DEFAULT_COLLECTION_NAME
collectionName
- the name of the collection to be used for storing and reading user dataMongoAuth setUsernameField(String fieldName)
DEFAULT_USERNAME_FIELD
fieldName
- the name of the field to be usedMongoAuth setPasswordField(String fieldName)
DEFAULT_PASSWORD_FIELD
fieldName
- the name of the field to be usedMongoAuth setRoleField(String fieldName)
DEFAULT_ROLE_FIELD
. Roles are expected to
be saved as JsonArrayfieldName
- the name of the field to be usedMongoAuth setPermissionField(String fieldName)
DEFAULT_PERMISSION_FIELD
.
Permissions are expected to be saved as JsonArrayfieldName
- the name of the field to be usedMongoAuth setUsernameCredentialField(String fieldName)
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)
. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD
fieldName
- the name of the field to be usedMongoAuth setPasswordCredentialField(String fieldName)
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)
. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD
fieldName
- the name of the field to be usedMongoAuth setSaltField(String fieldName)
HashStrategy.setSaltStyle(HashSaltStyle)
is
set to HashSaltStyle.COLUMN
fieldName
- the name of the field to be usedString getCollectionName()
DEFAULT_COLLECTION_NAME
String getUsernameField()
DEFAULT_USERNAME_FIELD
String getPasswordField()
DEFAULT_PASSWORD_FIELD
String getRoleField()
DEFAULT_ROLE_FIELD
. Roles are expected to
be saved as JsonArrayString getPermissionField()
DEFAULT_PERMISSION_FIELD
.
Permissions are expected to be saved as JsonArrayString getUsernameCredentialField()
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)
. Defaults to DEFAULT_CREDENTIAL_USERNAME_FIELD
String getPasswordCredentialField()
AuthProvider.authenticate(JsonObject, io.vertx.core.Handler)
. Defaults to DEFAULT_CREDENTIAL_PASSWORD_FIELD
String getSaltField()
HashStrategy.setSaltStyle(HashSaltStyle)
is
set to HashSaltStyle.COLUMN
MongoAuth setHashStrategy(HashStrategy hashStrategy)
hashStrategy
- the HashStrategy
to be setHashStrategy getHashStrategy()
HashStrategy
MongoAuth setHashAlgorithm(HashAlgorithm hashAlgorithm)
hashAlgorithm
- the HashAlgorithm
to be setvoid insertUser(String username, String password, List<String> roles, List<String> permissions, Handler<AsyncResult<String>> resultHandler)
username
- the username to be setpassword
- the passsword in clear text, will be adapted following the definitions of the defined HashStrategy
roles
- a list of roles to be setpermissions
- a list of permissions to be setresultHandler
- the ResultHandler will be provided with the id of the generated recordCopyright © 2023 Eclipse. All rights reserved.