Auth configuration
TALK ABOUT THE REQ.USER FIELD !!
Login
The object login is composed by:
- stateless: Boolean indicating whether the auth mode is statefull or stateless (default to true: stateless)
- key: The field that the system will take as the username field
- password: The field that the system will take as the password field
- model: An array of model names indicating where the login system has to search the users or identities
- function (Optional): Custom function for login users. The definition of the custom funcion must be:
The callback must apply 3 parameters: (statusCode, outMessage, userObject)function(key, password, callback)
Oauth (GERARD)
Crypto
Tokens
- token.secret: The secret user for signing the token
- token.fields: The fields that the signed token will contain. These fields will be available in the application when the user is logged in
- token.publicFields: The fields that will be returned to the user when a success login happens
- token.expiresInMinutes: The expiration time in minutes of the token
- token.logoutInMillis: The maximum time of inactivity before the user is logged out
- token.magicTokens: An object containing the specific tokens that the application will always accept. For example:
"token.magicTokens": { "magicToken1": { "name": 'admin', "displayName": 'admin', "role": 'admin' }, "magicToken2": { "name": 'user', "displayName": 'user', "role": 'user' } }
Example
module.exports = {
login: {
stateless: true, // Keep state (tokens and its timers) allowing logout
key: "niceName",
password: "password",
model: ["User"],
function: customLogin
},
crypt_key: 'encryption secret',
sign_key: 'signing secret',
storage: storage,
authorize_uri: '/oauth/authorize',
access_token_uri: '/oauth/token',
token_expiration: 3600,
refresh_token: true,
persist_refreshtoken: true,
persist_accesstoken: true,
debug: true,
"token.secret": "mySecret",
"token.fields": ['_id', 'email', 'role', 'niceName'],
"token.publicFields": ['role'],
"token.expiresInMinutes": 1440, //Expiration time -> 1 day
"token.logoutInMillis": 600000, //Inactivity time to force logOut -> 10 minutes
"token.magicTokens": {
"magicToken1": {
"name": 'admin',
"displayName": 'admin',
"role": 'admin'
},
"magicToken2": {
"name": 'user',
"displayName": 'user',
"role": 'user'
}
}
};