Reference Source
public class | source

AuthenticationManager

Extends:

devapt-core-common/dist/js/base/errorable~ErrorablePluginsManager → AuthenticationManager

Authentication class to manage authentication plugins.

Constructor Summary

Public Constructor
public

constructor(arg_runtime: RuntimeBase, arg_log_context: string | undefined, arg_logger_manager: LoggerManager): nothing

Create an Authentication manager class: load and create all authentication plugins.

Member Summary

Public Members
public
public
public
public
public

Method Summary

Public Methods
public

authenticate(arg_credentials: Credentials): Promise

Authenticate a user with giving credentials.

public

Check request credentials authentication.

public

Error wrapper - unknow request credentials format.

public

error_bad_digest_method(arg_digest_method: string): nothing

Error wrapper - unknow digest method.

public

error_bad_encoding_method(arg_encoding_method: string): nothing

Error wrapper - unknow encoding method.

public

error_bad_plugin(arg_plugin_mode: string): nothing

Error wrapper - error during plugin loading.

public

get_credentials(arg_request: object): Credentials | undefined

Get request credentials from headers.

public

hash_password(arg_password: string, arg_digest_method: string | undefined, arg_encoding_method: string | undefined): string

Hash a password.

public

load(arg_settings: object): nothing

Load security settings.

public

load_plugin(arg_settings: object): boolean

Load security plugin from settings.

Inherited Summary

From class PluginsManager
public
public
public
private
public

enabled_plugin(arg_name: string): Plugin

Get a enabled plugin by its name.

public

error_already_registered(arg_plugin_name: string): nothing

Error wrapper - on registering an already registered plugin

public

error_not_registered(arg_plugin_name: string): nothing

Error wrapper - a plugin is not registered

public

Get class name.

public

get_plugins(): array

Get registered plugins list.

public
public

get_typed_plugins(arg_type_or_types: string | array): array

Get registered plugins list with a filtered type.

public

load(arg_plugins: array): nothing

Load a map of plugins.

public

load_at_first(arg_plugin: Plugin): nothing

Load plugin at first position

public

plugin(arg_name: string, arg_enabled: boolean): Plugin

Get a registered plugin by its name and its enabled flag.

public

register_plugin(arg_plugin: object, arg_position: integer): object

Register a plugin to be used later, do not active it now.

public

registered_plugin(arg_name: string): Plugin

Get a registered plugin by its name.

public

Unregister a registered plugin and disble it before if needed.

Public Constructors

public constructor(arg_runtime: RuntimeBase, arg_log_context: string | undefined, arg_logger_manager: LoggerManager): nothing source

Create an Authentication manager class: load and create all authentication plugins. AuthenticationWrapper use created plugins.

Override:

PluginsManager#constructor

Params:

NameTypeAttributeDescription
arg_runtime RuntimeBase

runtime.

arg_log_context string | undefined

optional.

arg_logger_manager LoggerManager

logger manager object (optional).

Return:

nothing

Public Members

public authentication_default_plugins: * source

public authentication_is_enabled: boolean source

public authentication_mode: * source

public authentication_plugins: * source

public is_authentication_manager: boolean source

Public Methods

public authenticate(arg_credentials: Credentials): Promise source

Authenticate a user with giving credentials.

Params:

NameTypeAttributeDescription
arg_credentials Credentials

credentials object.

Return:

Promise

a promise of boolean.

public check_request_authentication(arg_request: object): boolean source

Check request credentials authentication. Request format: req.username=... req.authorization={ scheme: <Basic|Signature|...>, credentials: <Undecoded value of header>, basic: { username: $user password: $password } }

Params:

NameTypeAttributeDescription
arg_request object

request object.

Return:

boolean

public error_bad_credentials_format(): nothing source

Error wrapper - unknow request credentials format.

Return:

nothing

public error_bad_digest_method(arg_digest_method: string): nothing source

Error wrapper - unknow digest method.

Params:

NameTypeAttributeDescription
arg_digest_method string

digest method name.

Return:

nothing

public error_bad_encoding_method(arg_encoding_method: string): nothing source

Error wrapper - unknow encoding method.

Params:

NameTypeAttributeDescription
arg_encoding_method string

encoding method name.

Return:

nothing

public error_bad_plugin(arg_plugin_mode: string): nothing source

Error wrapper - error during plugin loading.

Params:

NameTypeAttributeDescription
arg_plugin_mode string

plugin mode.

Return:

nothing

public get_credentials(arg_request: object): Credentials | undefined source

Get request credentials from headers. Request format: req.username=... req.authorization={ scheme: <Basic|Signature|...>, credentials: <Undecoded value of header>, basic: { username: $user password: $password } }

Params:

NameTypeAttributeDescription
arg_request object

request object.

Return:

Credentials | undefined

credentials instance.

public hash_password(arg_password: string, arg_digest_method: string | undefined, arg_encoding_method: string | undefined): string source

Hash a password.

Params:

NameTypeAttributeDescription
arg_password string

password to hash.

arg_digest_method string | undefined

digest method name (sha1,sha256,sha384,sha512,md5)

arg_encoding_method string | undefined

encoding method name (hex,utf8,utf16,binary,base64,hexstr)

Return:

string

hashed password

public load(arg_settings: object): nothing source

Load security settings.

Override:

PluginsManager#load

Params:

NameTypeAttributeDescription
arg_settings object

authentication settings (Immutable object).

Return:

nothing

public load_plugin(arg_settings: object): boolean source

Load security plugin from settings.

Params:

NameTypeAttributeDescription
arg_settings object

authentication settings (Immutable object).

Return:

boolean