Supabase.Auth.Types.Provider (supabase_auth v1.0.1)

View Source

Custom Ecto type for OAuth provider validation.

Supports both built-in providers and custom providers. Built-in providers can be passed as atoms (:github) or strings ("github"). Inputs are normalized to lowercase before validation. Custom providers must use the custom:identifier format with lowercase identifiers.

Built-in providers are represented as atoms in Elixir (for backward compatibility). Custom providers are represented as strings.

Built-in Providers

apple, azure, bitbucket, discord, email, facebook, figma, github, gitlab, google, kakao, keycloak, linkedin, linkedin_oidc, notion, phone, slack, spotify, twitch, twitter, workos, zoom, fly

Custom Providers

Custom providers use lowercase identifiers in the format custom:identifier. For example:

  • "custom:mycompany"
  • "custom:sso-provider"

Examples

iex> cast(:github)
{:ok, :github}

iex> cast("google")
{:ok, :google}

iex> cast("invalid:provider")
:error

Summary

Functions

Returns the list of built-in provider names.

Casts the value to a provider.

Callback implementation for Ecto.Type.dump/1.

Callback implementation for Ecto.Type.embed_as/1.

Callback implementation for Ecto.Type.equal?/2.

Callback implementation for Ecto.Type.load/1.

Callback implementation for Ecto.Type.type/0.

Checks if a provider identifier is valid.

Functions

builtins()

@spec builtins() :: [atom()]

Returns the list of built-in provider names.

cast(value)

@spec cast(term()) :: {:ok, atom() | String.t()} | :error

Casts the value to a provider.

Accepts atoms (for built-in providers) and strings (for both built-in and custom). String inputs are trimmed and lowercased before validation.

dump(value)

@spec dump(term()) :: {:ok, String.t()} | :error

Callback implementation for Ecto.Type.dump/1.

embed_as(_)

Callback implementation for Ecto.Type.embed_as/1.

equal?(term1, term2)

Callback implementation for Ecto.Type.equal?/2.

load(value)

@spec load(term()) :: {:ok, atom() | String.t()} | :error

Callback implementation for Ecto.Type.load/1.

type()

@spec type() :: :string

Callback implementation for Ecto.Type.type/0.

valid_provider?(provider)

@spec valid_provider?(term()) :: boolean()

Checks if a provider identifier is valid.

Built-in providers must be in the known list. Custom providers must match lowercase custom:identifier.

Expects a normalized lowercase provider string.