Provider factory for authenticating to some resource.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


build status npm version npm downloads

Provider factory for authenticating to some resource.

Table of contents

  1. Installation
  2. Usage
  3. Example
  4. TODO


npm install provide-authentication --save


provideAuthentication (Object provider)

Adds (or wraps/appends) the necessary actions, reducers, replication, etc. to the provider to enable authentication.

You can include the following extra arguments (in this order) to customize the action/reducer keys:

  • String name - defaults to provider.defaultKey, then provider.key, then "resource"
  • String idKey - defaults to "id"
  • String nameKey - defaults to "name"
  • String passwordKey - defaults to "password"
  • String errorKey - defaults to "error"
  • String createKey - defaults to "create"
  • String authenticateKey - defaults to "authenticate"
  • Boolean unique - defaults to true, ensures unique states for the nameKey, which is useful for things like unique user names and will authenticate based on the nameKey; if unique is false, authentication must occur by using the idKey; this argument is determined by checking the last argument, so you can disable uniqueness by including false as your last argument, regardless of the number of other arguments

The above defaults would create the following actions:

  • createResource (Object state)
  • authenticateResource (Object state)

And would expect the following reducers to exist:

  • resourceId
  • resourceName (ensures queryable replication if unique)

And would ensure that the following reducers exist:

  • resourceError
  • resourcePasswordHash (ensures replication)
  • resourcePasswordHasher (defaults to initial state only)
  • resourcePasswordSaltRounds (defaults to initial state only)

And would also ensure that resourceError is within clientStateKeys while excluding resourcePasswordHash, resourcePasswordHasher, and resourcePasswordSaltRounds by default.


See provide-user, which first creates a user resource provider using provide-crud, and then adds authentication to it using this provider factory.

Also see Lumbur's UserLogIn component for usage.