Xirsys.XTurn.Auth.Client (xturn v2.0.0)

Copy Markdown View Source

GenServer-backed ephemeral long-term TURN credential store.

What problem this solves

Operators and the HTTP API need to provision username/password pairs for WebRTC clients without a separate database. This process creates random or explicit credentials, writes them to Auth.Table, indexes USERHASH for privacy-preserving lookup, and expires rows after @auth_lifetime ms.

Use create_user/1, create_user/2, or add_user/4 from the REST API or application code; authentication handlers call get_details/1 and get_details_by_hash/1 during Allocate.

RFCs

  • RFC 8489 (long-term credentials, USERHASH, MESSAGE-INTEGRITY)
  • RFC 8656 (TURN requires long-term credentials, pt.5)

Summary

Functions

Stores explicit username/pass for ns and peer_id.

Returns a specification to start this module under a supervisor.

Generates a random username/password for namespace ns with empty peer_id.

Generates a random username/password for ns and peer_id.

Looks up credentials by username.

Looks up credentials by USERHASH (SHA-256 of username:realm).

Starts the auth GenServer (registered name __MODULE__).

Functions

add_user(username, pass, ns, peer_id)

Stores explicit username/pass for ns and peer_id.

Returns {:ok, user, pass}.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_user(ns)

Generates a random username/password for namespace ns with empty peer_id.

Returns {:ok, username, password}.

create_user(ns, peer_id)

Generates a random username/password for ns and peer_id.

Returns {:ok, username, password}.

get_details(username)

Looks up credentials by username.

Returns {:ok, pass, ns, peer_id} or :error.

get_details_by_hash(hash)

Looks up credentials by USERHASH (SHA-256 of username:realm).

Returns {:ok, username, pass, ns, peer_id} or :error.

start_link()

Starts the auth GenServer (registered name __MODULE__).