Noizu.MCP.Auth.WWWAuthenticate (Noizu MCP v0.1.2)

Copy Markdown View Source

Parse and format WWW-Authenticate challenges (RFC 9110 §11.6.1), as used by the MCP authorization spec to point clients at protected-resource metadata and signal insufficient_scope step-up.

Summary

Functions

Format a challenge header value. params is an enumerable of name/value pairs.

Parse a challenge header value.

Types

t()

@type t() :: %Noizu.MCP.Auth.WWWAuthenticate{
  params: %{optional(String.t()) => String.t()},
  scheme: String.t()
}

Functions

format(scheme \\ "Bearer", params)

@spec format(String.t(), [{String.t() | atom(), String.t()}] | map()) :: String.t()

Format a challenge header value. params is an enumerable of name/value pairs.

parse(header)

@spec parse(String.t() | nil) :: t() | nil

Parse a challenge header value.

iex> Noizu.MCP.Auth.WWWAuthenticate.parse(
...>   ~s(Bearer resource_metadata="https://x/.well-known/oauth-protected-resource", error="invalid_token")
...> )
%Noizu.MCP.Auth.WWWAuthenticate{
  scheme: "Bearer",
  params: %{
    "resource_metadata" => "https://x/.well-known/oauth-protected-resource",
    "error" => "invalid_token"
  }
}