# `Threadline.OperatorSurface.Auth`
[🔗](https://github.com/szTheory/threadline/blob/v1.2.0/lib/threadline/operator_surface/auth.ex#L2)

Uses host authorization callbacks to admit or halt Threadline operator LiveView mounts.

# `on_mount_opt`

```elixir
@type on_mount_opt() ::
  {:authorize_fn, function()}
  | {:scope_query_fn, function()}
  | Threadline.repo_opt()
  | {:schemas, %{optional(String.t() | atom()) =&gt; module()}}
  | {:theme, :dark | :light | :system | String.t()}
  | {:exports, boolean()}
  | {:export_authorize_fn, function()}
  | {:coverage_authorize_fn, function()}
  | {:policy_authorize_fn, function()}
  | {:evidence_authorize_fn, function()}
```

An option read by the operator LiveView authorization hook.

# `on_mount_params`

```elixir
@type on_mount_params() :: %{optional(String.t()) =&gt; String.t()}
```

String-keyed route parameters passed to an operator LiveView mount.

# `on_mount_session`

```elixir
@type on_mount_session() :: %{
  optional(String.t() | atom()) =&gt; on_mount_session_value()
}
```

String- or atom-keyed session values passed to an operator LiveView mount.

# `on_mount_session_value`

```elixir
@type on_mount_session_value() ::
  atom()
  | number()
  | bitstring()
  | pid()
  | port()
  | reference()
  | function()
  | tuple()
  | maybe_improper_list(on_mount_session_value(), on_mount_session_value())
  | %{optional(on_mount_session_value()) =&gt; on_mount_session_value()}
```

An opaque host-defined value carried in the LiveView session.

# `on_mount`

```elixir
@spec on_mount(
  [on_mount_opt()],
  on_mount_params(),
  on_mount_session(),
  Phoenix.LiveView.Socket.t()
) :: {:cont, Phoenix.LiveView.Socket.t()} | {:halt, Phoenix.LiveView.Socket.t()}
```

Allows or halts an operator LiveView mount using the host authorization callback.

The callback receives the socket-shaped value and may return `:ok`, `true`,
or `{:ok, scope}` to continue. Other results or callback exceptions halt the
mount and redirect to `/`.

## Mount options

- `:authorize_fn` — function. Optional here; the router macro requires a secure pipeline, this callback, or explicit acknowledgement.
- `:scope_query_fn` — function. Optional. Applies host-owned query scoping.
- `:repo` — `Ecto.Repo` module. Optional. Assigned to the LiveView socket.
- `:schemas` — map from host table names to Ecto schema modules. Optional.
- `:theme` — `:dark`, `:light`, or `:system`. Defaults to `:dark`.
- `:exports` — boolean. Defaults to `true`; enables or disables export affordances.
- `:export_authorize_fn` — function. Optional. Applies export-specific authorization.
- `:coverage_authorize_fn` — function. Optional. Defaults to deny access to coverage.
- `:policy_authorize_fn` — function. Optional. Defaults to deny access to policy views.
- `:evidence_authorize_fn` — function. Optional. Defaults to deny access to evidence.

Other mount options are consumed by the router macro or companion hooks.

## Returns

- `{:cont, socket}` — authorization allows the mount.
- `{:halt, socket}` — authorization denies or errors; the socket is redirected.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
