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.
attempt
_auth.attempt() : boolean
Return
( boolean )
attemptReject
_auth.attemptReject() : boolean
Return
( boolean )
_auth.attemptReject(reject: boolean) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
reject | boolean |
Return
( Auth )
attemptRejectWithData
_auth.attemptRejectWithData() : Values
Return
( Values )
_auth.attemptRejectWithData(data: java.util.List) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | java.util.List |
Return
( Auth )
_auth.attemptRejectWithData(data: Config | Exec | Header | Req | Res | Values | DataSchema) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Config | Exec | Header | Req | Res | Values | DataSchema |
Return
( Auth )
_auth.attemptRejectWithData(data: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Auth )
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.
checkUserInJWTGroups
_auth.checkUserInJWTGroups(userId: int) : boolean
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
userId | int |
Return
( boolean )
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 )
getAttemptRejectWithData
_auth.getAttemptRejectWithData(data: Values) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Values )
getJWTGroups
_auth.getJWTGroups() : Values
Return
( Values )
getProviderConfig
_auth.getProviderConfig(providerCode: string) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
providerCode | string |
Return
( Values )
getSignInAbortWithData
_auth.getSignInAbortWithData(data: Values) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Values )
getSignInExtraData
_auth.getSignInExtraData(data: Values) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
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.
isAttempt
_auth.isAttempt() : boolean
Return
( boolean )
isAttemptReject
_auth.isAttemptReject() : boolean
Return
( boolean )
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.
isSignInAbort
_auth.isSignInAbort() : boolean
Return
( boolean )
jwtAccessExpires
_auth.jwtAccessExpires() : int
Description
Sets the time of expiration of the token to the settings in configs.
Return
( int )
jwtCheckToken
_auth.jwtCheckToken(token: string) : boolean
Description
This method verify the token.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
token | string | Token to be verify. |
Return
( boolean )
Returns the validation.
jwtCheckTokenDataExpiration
_auth.jwtCheckTokenDataExpiration(dbToken: Values) : boolean
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
dbToken | Values |
Return
( boolean )
jwtCreateAccessToken
_auth.jwtCreateAccessToken(userId: int, contextData: Values) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
userId | int | |
contextData | Values |
Return
( Values )
_auth.jwtCreateAccessToken(userId: Values) : Values
Description
This method access to the token of a user and returns the content.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
userId | Values | Id of user. |
Return
( Values )
Returns the content of the user inserted.
jwtDBRecord
_auth.jwtDBRecord(token: string) : Values
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
token | string |
Return
( Values )
jwtData
_auth.jwtData() : Values
Return
( Values )
jwtEnabled
_auth.jwtEnabled() : boolean
Description
Verify if the JWT is enable.
Return
( boolean )
Returns if is enabled.
_auth.jwtEnabled(enabled: boolean) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
enabled | boolean |
Return
( Auth )
jwtGroups
_auth.jwtGroups() : Values
Return
( Values )
jwtInvalidateToken
_auth.jwtInvalidateToken() : boolean
Return
( boolean )
_auth.jwtInvalidateToken(token: string) : boolean
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
token | string |
Return
( boolean )
jwtKey
_auth.jwtKey() : javax.crypto.SecretKey
Return
( javax.crypto.SecretKey )
jwtRefreshAccessToken
_auth.jwtRefreshAccessToken(refreshToken: string) : Values
Description
Replaces an old token for the new on inserted.
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
refreshToken | string | Replace token. |
Return
( Values )
Returns the updated token.
jwtRefreshExpires
_auth.jwtRefreshExpires() : int
Description
Updates the time of expiration of the token to the settings in configs.
Return
( int )
jwtSignIn
_auth.jwtSignIn(userId: int, contextData: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
userId | int | |
contextData | Values |
Return
( Auth )
jwtSignInData
_auth.jwtSignInData() : Values
Return
( Values )
jwtToken
_auth.jwtToken() : string
Description
Verify if exists an authenticated token.
Return
( string )
Returns the token.
jwtTokenCheck
_auth.jwtTokenCheck() : boolean
Description
Verify if a token exists.
Return
( boolean )
Returns the validation.
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.
setAttemptReject
_auth.setAttemptReject(reject: boolean) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
reject | boolean |
Return
( Auth )
setAttemptRejectWithData
_auth.setAttemptRejectWithData(data: java.util.List) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | java.util.List |
Return
( Auth )
_auth.setAttemptRejectWithData(data: Config | Exec | Header | Req | Res | Values | DataSchema) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Config | Exec | Header | Req | Res | Values | DataSchema |
Return
( Auth )
_auth.setAttemptRejectWithData(data: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Auth )
setSignInAbort
_auth.setSignInAbort(abort: boolean) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
abort | boolean |
Return
( Auth )
setSignInAbortWithData
_auth.setSignInAbortWithData(data: java.util.List) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | java.util.List |
Return
( Auth )
_auth.setSignInAbortWithData(data: Config | Exec | Header | Req | Res | Values | DataSchema) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Config | Exec | Header | Req | Res | Values | DataSchema |
Return
( Auth )
_auth.setSignInAbortWithData(data: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Auth )
setSignInExtraData
_auth.setSignInExtraData(data: java.util.List) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | java.util.List |
Return
( Auth )
_auth.setSignInExtraData(data: Config | Exec | Header | Req | Res | Values | DataSchema) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Config | Exec | Header | Req | Res | Values | DataSchema |
Return
( Auth )
_auth.setSignInExtraData(data: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Auth )
signInAbort
_auth.signInAbort() : boolean
Return
( boolean )
_auth.signInAbort(abort: boolean) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
abort | boolean |
Return
( Auth )
signInAbortWithData
_auth.signInAbortWithData() : Values
Return
( Values )
_auth.signInAbortWithData(data: java.util.List) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | java.util.List |
Return
( Auth )
_auth.signInAbortWithData(data: Config | Exec | Header | Req | Res | Values | DataSchema) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Config | Exec | Header | Req | Res | Values | DataSchema |
Return
( Auth )
_auth.signInAbortWithData(data: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Auth )
signInExtraData
_auth.signInExtraData() : Values
Return
( Values )
_auth.signInExtraData(data: java.util.List) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | java.util.List |
Return
( Auth )
_auth.signInExtraData(data: Config | Exec | Header | Req | Res | Values | DataSchema) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Config | Exec | Header | Req | Res | Values | DataSchema |
Return
( Auth )
_auth.signInExtraData(data: Values) : Auth
Attributes
NAME | TYPE | DESCRIPTION |
---|---|---|
data | Values |
Return
( Auth )