AuthShield v0.0.4 AuthShield.Credentials.Schemas.TOTP View Source

TOTP (Time-based One Time Password) shema model.

We generates a one-time password from sharing a secret key randomly generated that should be known only for us and the client.

To see more about how we generate the qrcode check EQRCode.

Link to this section Summary

Types

t()

Abstract totp module type.

Functions

Generates an Ecto.Changeset struct with the changes.

Generates and random string that contains the alphabet letters and is used as __MODULE__ secret.

Generates and TOTP code from its secret and options

Link to this section Types

Link to this type

t()

View Source
t() :: %AuthShield.Credentials.Schemas.TOTP{
  __meta__: term(),
  digits: integer(),
  email: term(),
  id: binary(),
  inserted_at: NaiveDateTime.t(),
  issuer: String.t(),
  period: integer(),
  qrcode_base64: String.t(),
  secret: String.t(),
  updated_at: NaiveDateTime.t(),
  user: AuthShield.Resources.Schemas.User.t(),
  user_id: term()
}

Abstract totp module type.

Link to this section Functions

Link to this function

changeset(model, params)

View Source
changeset(model :: t(), params :: map()) :: Ecto.Changeset.t()

Generates an Ecto.Changeset struct with the changes.

It defines validations and also generates the secret if necessary.

Link to this function

generate_random_secret()

View Source
generate_random_secret() :: String.t()

Generates and random string that contains the alphabet letters and is used as __MODULE__ secret.

Link to this function

generate_totp(secret, period, digits, datetime)

View Source
generate_totp(
  secret :: String.t(),
  period :: integer(),
  digits :: integer(),
  datetime :: Datetime.t()
) :: String.t()

Generates and TOTP code from its secret and options