MishkaCmsCore.Accounts.SecondFactor.Pending (Mishka CMS Core v0.0.1)

Copy Markdown View Source

The code step of a sign-in that could not ask for the code itself — one with a provider such as Google or GitHub.

MishkaCmsCoreWeb.AuthController opens no session for an account with an authenticator. It hands the sign-in page token/1 instead: AshAuthentication's own token, with the purpose "second_factor", for that account, for five minutes, which is no bearer credential and signs nobody in. The page's code step sends it back with a code to sign_in_with_second_factor (prepare/3), where it is checked, spent, and exchanged for the short sign-in token the password sign-in hands out — the same route then opens the session.

Summary

Functions

Callback implementation for Ash.Resource.Preparation.init/1.

The preparation of sign_in_with_second_factor, before the code is asked: only the account the token argument names, while it is a live "second_factor" token of this site; and after the code passed, the token spent and a sign-in token on the account's :token metadata.

A token that names user as waiting for its code, for five minutes.

Functions

init(opts)

Callback implementation for Ash.Resource.Preparation.init/1.

prepare(query, opts, context)

The preparation of sign_in_with_second_factor, before the code is asked: only the account the token argument names, while it is a live "second_factor" token of this site; and after the code passed, the token spent and a sign-in token on the account's :token metadata.

supports(opts)

Callback implementation for Ash.Resource.Preparation.supports/1.

temporal_safe?(opts)

Callback implementation for Ash.Resource.Preparation.temporal_safe?/1.

token(user)

@spec token(MishkaCmsCore.Accounts.User.t()) :: {:ok, String.t()} | {:error, term()}

A token that names user as waiting for its code, for five minutes.