mix ash_authentication.add_strategy (ash_authentication v5.0.0-rc.7)

Copy Markdown View Source

Adds the provided strategy or strategies to your user resource

This task will add the provided strategy or strategies to your user resource.

The following strategies are available. For all others, see the relevant documentation for setup

  • password - Register and sign in with a username/email and a password.
  • magic_link - Register and sign in with a magic link, sent via email to the user.
  • otp - Sign in with a short one-time password sent via email or SMS.
  • api_key - Sign in with an API key.
  • totp - Authenticate with a time-based one-time password (TOTP).
  • recovery_code - Authenticate with one-time recovery codes as a 2FA fallback.
  • github - Sign in with GitHub.
  • google - Sign in with Google.
  • apple - Sign in with Apple.
  • auth0 - Sign in with Auth0.
  • microsoft - Sign in with Microsoft.
  • okta - Sign in with Okta.
  • slack - Sign in with Slack.
  • oidc - Sign in with a generic OpenID Connect provider.
  • oauth2 - Sign in with a generic OAuth2 provider.

Each strategy can also be added directly with its own task:

Example

mix ash_authentication.add_strategy password

Options

  • --user, -u - The user resource. Defaults to YourApp.Accounts.User
  • --identity-field, -i - The field on the user resource that will be used to identify the user. Defaults to email

Password options

  • hash-provider - The hash provider to use, either bcrypt or argon2. Defaults to bcrypt.

TOTP options

  • --mode, -m - Either primary or 2fa. Defaults to 2fa.
  • --name, -n - The name of the TOTP strategy. Defaults to totp.

Summary

Functions

igniter(igniter)

Callback implementation for Igniter.Mix.Task.igniter/1.