Normalized claims for a validated OAuth 2.1 access token.
An Urchin.Auth.TokenValidator returns one of these from validate/2. The transport
surfaces it to handlers as ctx.auth (see Urchin.Context), so a handler can make
per-tool authorization decisions:
def call_tool("delete", _args, ctx) do
if Urchin.Auth.Claims.has_scope?(ctx.auth, "files:write") do
# ...
else
{:error, "files:write scope required"}
end
endfrom_map/1 converts a decoded JWT payload or an RFC 7662 introspection response into
this struct, normalizing the OAuth/JWT field names (sub, aud, scope, exp, ...).
Summary
Functions
Builds a Claims struct from a decoded token payload (string-keyed map).
Returns true when the claims grant the given scope.
Returns true when the claims grant every scope in required.
Types
Functions
Builds a Claims struct from a decoded token payload (string-keyed map).
Recognized fields: sub, client_id/azp, exp, aud (string or list),
scope (space-delimited string) and/or scp/scopes (string or list). The full
payload is preserved under :claims for custom checks.
Returns true when the claims grant the given scope.
Returns true when the claims grant every scope in required.