Auth
Gathers Netuno's authentication operations, providers, encryption, and others.
if (_auth.isJWT() && _auth.isAdmin()) {
_log.info('Administrator logged with JWT Token!')
}
allProvidersConfig
_auth.allProvidersConfig() : Values
Description
Gets all the authentication providers configuration.
How To Use
// Gets the Authentication Providers Settings.
const allProvidersConfig = _auth.allProvidersConfig()
_log.info('Authentication Providers Configuration', allProvidersConfig)
Return
( Values )
All authentication providers settings.
check
_auth.check(password: string) : boolean
Description
Checks if the password is valid for the authenticated user.
How To Use
if (_auth.check(_req.getString('pass'))) {
_log.info('Valid password!')
} else {
_log.info('Invalid password!')
}
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
password | string | Password. |
Return
( boolean )
Returns the result of validating authentication data.
_auth.check(username: string, password: string) : boolean
Description
Checks if the authentication data, user and password, are valid.
How To Use
if (_auth.check(_req.getString('user'), _req.getString('pass'))) {
_log.info('Valid login!')
} else {
_log.info('Invalid login!')
}
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
username | string | Username. |
password | string | Password. |
Return
( boolean )
Returns the result of the validating authentication data.
crypt
_auth.crypt(username: string, password: string) : string
Description
Generates a secure encrypted password for a given user.
How To Use
// Generates the secure password to a user.
_log.info('Secure Password: '+ _auth.crypt('my-user', 'my-pass'))
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
username | string | Username. |
password | string | Password. |
Return
( string )
Returns strong password encryption.
getAllProvidersConfig
_auth.getAllProvidersConfig() : Values
Return
( Values )
getProviderConfig
_auth.getProviderConfig(providerCode: string) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
providerCode | string |
Return
( Values )
isAdmin
_auth.isAdmin() : boolean
Description
Checks if the user that is authenticated is administrator.
How To Use
if (_auth.isAdmin()) {
_log.info('Admin logged in!')
}
Return
( boolean )
If the user that is authenticated is an admin (administrator) returns true.
isAuthenticated
_auth.isAuthenticated() : boolean
Description
Indicates whether there is someone authenticated processing the request.
How To Use
if (_auth.isAuthenticated()) {
_log.info('There is someone authenticated.')
}
Return
( boolean )
If someone is authenticated, it returns true.
isDev
_auth.isDev() : boolean
Description
Checks if the user authenticated is a developer.
How To Use
if (_auth.isDev()) {
_log.info('Developer logged in!')
}
Return
( boolean )
if the user authenticated is a dev (developer) returns true.
isJWT
_auth.isJWT() : boolean
Description
Indicates whether the user is authenticated with JSON Web Token.
How To Use
if (_auth.isJWT()) {
_log.info('Logged in with JWT!')
}
Return
( boolean )
If the user is authenticated with JSON Web Token returns true.
isProviderEnabled
_auth.isProviderEnabled(providerCode: string) : boolean
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
providerCode | string |
Return
( boolean )
isSession
_auth.isSession() : boolean
Description
Indicates whether the user is authenticated with session.
How To Use
if (_auth.isSession()) {
_log.info('Logged in with session!')
}
Return
( boolean )
If the user is authenticated with JSON Web Token returns true.
load
_auth.load() : Auth
Description
Processes authentication settings.
How To Use
// Loads authentication settings.
_auth.load()
Return
( Auth )
Returns the default Auth resource.
logout
_auth.logout() : Auth
Description
Signs out the user authenticated.
How To Use
// Clears the authentication context.
_auth.logout()
Return
( Auth )
Returns the default Auth resource.
providerConfig
_auth.providerConfig(providerCode: string) : Values
Description
Gets one specific authentication provider configuration.
How To Use
// Gets authentication provider setting to each provider.
_log.info('Google Provider Configuration', _auth.providerConfig('google'))
_log.info('GitHub Provider Configuration', _auth.providerConfig('github'))
_log.info('Discord Provider Configuration', _auth.providerConfig('discord'))
_log.info('LDAP Provider Configuration', _auth.providerConfig('ldap'))
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
providerCode | string | Name of the provider configuration key, which can be: |
- github | ||
- discord | ||
- ldap |
Return
( Values )
The authentication provider configuration.
providerEnabled
_auth.providerEnabled(providerCode: string) : boolean
Description
Checks whether the authentication provider is active.
How To Use
// Checks enabled authentication providers.
_log.info('Google Provider Enabled', _auth.providerEnabled('google'))
_log.info('GitHub Provider Enabled', _auth.providerEnabled('github'))
_log.info('Discord Provider Enabled', _auth.providerEnabled('discord'))
_log.info('LDAP Provider Enabled', _auth.providerEnabled('ldap'))
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
providerCode | string | Name of the provider configuration key, which can be: |
- github | ||
- discord | ||
- ldap |
Return
( boolean )
If the authentication provider is active returns true.