WeaviateEx.Auth.OIDC (WeaviateEx v0.7.4)

View Source

OIDC (OpenID Connect) authentication support.

Provides functions for:

  • Discovering OIDC configuration from issuer
  • Obtaining tokens via client_credentials or password grant
  • Refreshing tokens

Example

# Discover OIDC configuration
{:ok, config} = OIDC.discover("https://auth.example.com")

# Get token with client credentials
auth = %{type: :oidc_client_credentials, client_id: "id", client_secret: "secret", scopes: []}
{:ok, token} = OIDC.get_token(config, auth)

# Refresh token
{:ok, new_token} = OIDC.refresh_token(config, token.refresh_token)

Summary

Functions

Discover OIDC configuration from the issuer's well-known endpoint.

Exchange credentials for an access token.

Parses scope string into list of scopes.

Refresh an access token using a refresh token.

Functions

discover(issuer_url)

@spec discover(String.t()) ::
  {:ok, WeaviateEx.Auth.OIDC.Config.t()} | {:error, term()}

Discover OIDC configuration from the issuer's well-known endpoint.

Example

{:ok, config} = OIDC.discover("https://auth.example.com")

get_token(config, auth)

@spec get_token(WeaviateEx.Auth.OIDC.Config.t(), map()) ::
  {:ok, WeaviateEx.Auth.OIDC.TokenResponse.t()} | {:error, term()}

Exchange credentials for an access token.

Supports both client_credentials and password grant types.

parse_scopes(scopes)

@spec parse_scopes(String.t() | [String.t()] | nil) :: [String.t()]

Parses scope string into list of scopes.

Handles both space-separated (OAuth standard) and comma-separated formats.

Examples

iex> OIDC.parse_scopes("openid profile email")
["openid", "profile", "email"]

iex> OIDC.parse_scopes("openid,profile,email")
["openid", "profile", "email"]

iex> OIDC.parse_scopes(["openid", "profile"])
["openid", "profile"]

iex> OIDC.parse_scopes(nil)
[]

refresh_token(config, refresh_token)

@spec refresh_token(WeaviateEx.Auth.OIDC.Config.t(), String.t()) ::
  {:ok, WeaviateEx.Auth.OIDC.TokenResponse.t()} | {:error, term()}

Refresh an access token using a refresh token.