Macaw.Auth.Native.SessionRecord (macaw_auth v0.4.1)

Copy Markdown View Source

A row of macaw_auth_sessions, the native backend's sessions, in the host's repo (mix macaw_auth.gen.migration writes the table's migration, separate from the users').

  • token_hash is the SHA-256 of the session's token, unique. The token itself goes to the client and is never written anywhere: a copy of the table signs nobody in.
  • user_id references macaw_auth_users; deleting a user deletes their sessions.
  • user_agent is truncated to 255 characters, so a client can't make the row as large as it likes.
  • completed_steps holds step names as strings ({:array, :string}, a native array on Postgres and JSON text on SQLite). They become the contract's atoms only by lookup among Macaw.Auth.steps/0, so a row can never create an atom.
  • last_used_at is what idle expiry reads; a request writes it at most hourly (Macaw.Auth.Native.Sessions).

Summary

Types

t()

@type t() :: %Macaw.Auth.Native.SessionRecord{
  __meta__: term(),
  completed_steps: term(),
  id: term(),
  inserted_at: term(),
  last_used_at: term(),
  remote_ip: term(),
  second_factor_passed: term(),
  token_hash: term(),
  updated_at: term(),
  user: term(),
  user_agent: term(),
  user_id: term()
}