AshAuthentication.Strategy.Totp.TotpUrlCalculation
(ash_authentication v5.0.0-rc.7)
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
endThe calculation will generate URIs like:
"otpauth://totp/MyApp:user@example.com?secret=BASE32SECRET&issuer=MyApp&period=30"
Summary
Functions
Callback implementation for Ash.Resource.Calculation.describe/1.
Callback implementation for Ash.Resource.Calculation.has_expression?/0.
Callback implementation for Ash.Resource.Calculation.strict_loads?/0.
Functions
Callback implementation for Ash.Resource.Calculation.describe/1.
Callback implementation for Ash.Resource.Calculation.has_expression?/0.
Callback implementation for Ash.Resource.Calculation.strict_loads?/0.