# Class: ChainAuth

## vertx-auth-common-js/chain_auth~ ChainAuth

#### new ChainAuth()

Chain several auth providers as if they were one. This is useful for cases where one want to authenticate across several providers, for example, database and fallback to passwd file.

Source:
  - vertx-auth-common-js/chain_auth.js, line 32

### Methods

#### append(other) → {ChainAuth}

Appends a auth provider to the chain.

##### Parameters:

Name | Type | Description
--- | --- | ---
`other` | AuthProvider | auth provider

Source:
  - vertx-auth-common-js/chain_auth.js, line 79

##### Returns:

self

Type
  ChainAuth

#### authenticate(authInfo, resultHandler)

Authenticate a user.

The first argument is a JSON object containing information for authenticating the user. What this actually contains depends on the specific implementation. In the case of a simple username/password based authentication it is likely to contain a JSON object with the following structure:

         {
           "username": "tim",
           "password": "mypassword"
         }

For other types of authentication it contain different information - for example a JWT token or OAuth bearer token.

If the user is successfully authenticated a User object is passed to the handler in an AsyncResult. The user object can then be used for authorisation.

##### Parameters:

Name | Type | Description
--- | --- | ---
`authInfo` | Object | The auth information
`resultHandler` | function | The result handler

Source:
  - vertx-auth-common-js/chain_auth.js, line 59

#### clear()

Clears the chain.

Source:
  - vertx-auth-common-js/chain_auth.js, line 107

#### remove(other) → {boolean}

Removes a provider from the chain.

##### Parameters:

Name | Type | Description
--- | --- | ---
`other` | AuthProvider | provider to remove

Source:
  - vertx-auth-common-js/chain_auth.js, line 94

##### Returns:

true if provider was removed, false if non existent in the chain.

Type
  boolean