AshAuthentication.Strategy.Totp.TotpUrlCalculation (ash_authentication v5.0.0-rc.4)

Copy Markdown View Source

Calculates the TOTP URL for a user record.

This calculation generates an otpauth:// URI suitable for encoding into a QR code. Users can scan the QR code with an authenticator app (like Google Authenticator or Authy) to set up TOTP-based authentication.

The calculation requires the user to have a TOTP secret already set up (typically via the setup action). If no secret is present, it returns nil.

Options

  • :strategy_name - The name of the TOTP strategy to use for configuration. This is required and is set automatically by the transformer.

Example

Given a user resource with TOTP configured:

defmodule MyApp.Accounts.User do
  use Ash.Resource, ...

  authentication do
    strategies do
      totp do
        identity_field :email
        issuer "MyApp"
      end
    end
  end
end

The calculation will generate URIs like:

"otpauth://totp/MyApp:user@example.com?secret=BASE32SECRET&issuer=MyApp&period=30"

Summary

Functions

describe(opts)

Callback implementation for Ash.Resource.Calculation.describe/1.

has_calculate?()

has_expression?()

Callback implementation for Ash.Resource.Calculation.has_expression?/0.

strict_loads?()

Callback implementation for Ash.Resource.Calculation.strict_loads?/0.