SteamOpenID (steam_openid v0.1.0)

Copy Markdown View Source

Helpers for implementing OpenID 2.0 authentication using Steam as the provider.

The flow is as follows:

  1. A login URL needs to be generated with generate_login_url/1; this is where you redirect your users to.
  2. The user logs in with Steam as usual, and is then redirected back to the :callback_uri that was passed to generate_login_url/1.
  3. In this redirect, Steam will include various query parameters. This payload must be verified with verify_callback_payload/2. If the payload was valid, the user's SteamID may be extracted from the payload with extract_claimed_id!/1.

Summary

Types

The payload sent to the callback endpoint by Steam.

The claimed user ID (SteamID).

Functions

Extracts the user's claimed ID (SteamID) from a valid callback payload.

Generates a URL you can redirect your users to for log-in.

Verifies the payload received by the log-in callback endpoint.

Types

callback_payload()

@type callback_payload() :: %{optional(binary()) => binary()}

The payload sent to the callback endpoint by Steam.

claimed_id()

@type claimed_id() :: SteamID.t()

The claimed user ID (SteamID).

login_url_options()

@type login_url_options() :: [{:callback_uri, URI.t()}]
  • :callback_uri (URI.t/0) - Required. The URI Steam should redirect back to after a successful log-in.

Functions

extract_claimed_id!(payload)

@spec extract_claimed_id!(callback_payload()) :: claimed_id()

Extracts the user's claimed ID (SteamID) from a valid callback payload.

This function should only be called with payloads that have been verified by verify_callback_payload/2.

generate_login_url(opts \\ [])

@spec generate_login_url(login_url_options()) :: URI.t()

Generates a URL you can redirect your users to for log-in.

Options

  • :callback_uri (URI.t/0) - Required. The URI Steam should redirect back to after a successful log-in.

is_callback_payload(term)

(macro)

verify_callback_payload(payload, opts \\ [])

@spec verify_callback_payload(callback_payload(), [option]) ::
  {:ok, callback_payload()}
  | {:error, SteamOpenID.VerifyCallbackPayloadError.t()}
when option: {:expected_host, binary()}

Verifies the payload received by the log-in callback endpoint.

Options

verify_callback_payload!(payload, opts \\ [])

Like verify_callback_payload/2, but raises in case of errors.