KMS.Principals.Factors.TOTP (kms v0.1.0)

Copy Markdown View Source

RFC 6238 TOTP factor provider for authenticator applications.

The shared TOTP seed is stored RMK-encrypted in factor config under "encrypted_secret". The seed is never returned in session challenges.

Summary

Functions

Builds RMK-encrypted factor config from an existing TOTP secret.

Builds a TOTP enrollment payload.

Generates a base32 TOTP secret.

Builds an otpauth://totp/... URI for authenticator app enrollment.

Verifies a user-provided TOTP code before storing an enrollment.

Functions

code_at(secret, unix_seconds, opts \\ [])

config(secret, opts \\ [])

Builds RMK-encrypted factor config from an existing TOTP secret.

current_code(secret, opts \\ [])

enrollment(issuer, account_name, opts \\ [])

Builds a TOTP enrollment payload.

Returns the secret, an otpauth:// URI for authenticator apps, and RMK-encrypted factor config suitable for KMS.create_principal_factor/3.

generate_secret(byte_count \\ 32)

Generates a base32 TOTP secret.

byte_count must be at least 20 bytes. The default is 32 bytes.

otpauth_uri(issuer, account_name, secret, opts \\ [])

Builds an otpauth://totp/... URI for authenticator app enrollment.

verify_enrollment(secret, code, opts \\ [])

Verifies a user-provided TOTP code before storing an enrollment.