OzMcp.Auth.Scopes (OzMcp v0.9.0)

Copy Markdown View Source

The scopes that a tool, a resource, a template or a prompt requires.

A list of required scopes means "all of them". The data lives in the field required_scopes of the struct of the entity. A map entity carries them like a struct: the boot of the instance reads the key and checks it and the key never reaches the client.

Summary

Functions

Check the value of a required_scopes declaration and return the scopes with no repeated entry. Raises ArgumentError.

All the scopes that the modules of the server require, sorted. The function reads the catalog of the server, which holds the scopes of the entities of each kind. It never calls list/0 of a module: the catalog was read one time, at the boot of the instance.

The scopes that the modules of one kind (:tools, :resources, :templates or :prompts) declare: the required_scopes of the entities of the kind, which the catalog holds. Sorted. Empty when the kind has no block, or when no entity of the kind needs a scope.

True when the principal holds all the scopes.

The required scopes of an entity. A map or nil has none. The bind stage of the pipeline (OzMcp.Pipeline.Bind) copies them into the field required_scopes of the bound entity, where the scope stage and the list filters read them.

The scope of a step-up challenge: the scopes that the principal holds, then the needed scopes that are not in the list. needed empty means the challenge_scopes of the server. A granted scope that is not an RFC 6749 scope token is dropped: it cannot go in the header.

The scopes_supported of the metadata document: the list that the server sets, or else the scopes that the modules of the server require, or nil when there is neither.

True when the principal can use the entity (the entity needs no scope, or the principal holds them).

Functions

check!(scopes)

@spec check!(term()) :: [String.t()]

Check the value of a required_scopes declaration and return the scopes with no repeated entry. Raises ArgumentError.

declared(server)

@spec declared(module()) :: [String.t()]

All the scopes that the modules of the server require, sorted. The function reads the catalog of the server, which holds the scopes of the entities of each kind. It never calls list/0 of a module: the catalog was read one time, at the boot of the instance.

declared(server, kind)

@spec declared(module(), atom()) :: [String.t()]

The scopes that the modules of one kind (:tools, :resources, :templates or :prompts) declare: the required_scopes of the entities of the kind, which the catalog holds. Sorted. Empty when the kind has no block, or when no entity of the kind needs a scope.

granted?(principal, scopes)

@spec granted?(OzMcp.Auth.Principal.t(), [String.t()]) :: boolean()

True when the principal holds all the scopes.

required(arg1)

@spec required(term()) :: [String.t()]

The required scopes of an entity. A map or nil has none. The bind stage of the pipeline (OzMcp.Pipeline.Bind) copies them into the field required_scopes of the bound entity, where the scope stage and the list filters read them.

step_up(principal, needed, challenge_scopes)

@spec step_up(OzMcp.Auth.Principal.t(), [String.t()], [String.t()]) :: [String.t()]

The scope of a step-up challenge: the scopes that the principal holds, then the needed scopes that are not in the list. needed empty means the challenge_scopes of the server. A granted scope that is not an RFC 6749 scope token is dropped: it cannot go in the header.

supported(server, arg2)

@spec supported(module(), map()) :: [String.t()] | nil

The scopes_supported of the metadata document: the list that the server sets, or else the scopes that the modules of the server require, or nil when there is neither.

visible?(entity, principal)

@spec visible?(term(), OzMcp.Auth.Principal.t()) :: boolean()

True when the principal can use the entity (the entity needs no scope, or the principal holds them).