Documentation
¶
Overview ¶
Package auth lowers what a document says about authentication: the security schemes it declares, and the requirements that name them.
It is a package of its own because both halves of the compiler reach it. The compiler's run lowers the schemes once, before anything references them; the service and operation walks lower requirements against the Registry that holds them. The requirements cannot sit in the root, which those walks may not import, and the schemes are the document's, no part of lowering an operation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func LowerSecuritySchemes ¶
func LowerSecuritySchemes(c lowering.Ctx) (map[ir.AuthID]ir.AuthScheme, []ir.Diagnostic)
LowerSecuritySchemes lowers every securitySchemes entry (docs/ir/auth.md), keyed by ids.Auth(name): the declared schemes the service walk builds its Registry from, so a requirement reaches a declared ID.
An entry that yields no mechanism lowers all the same, keyed by ids.UnresolvedAuth(name), so nothing can reach it as a declared scheme: one whose $ref resolves to nothing, reported at its own components pointer (see unresolvableScheme), and one naming no mechanism, reported the same way (see noMechanismDiag).
Types ¶
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry is every security scheme of one compile, keyed by ID: what the document's securitySchemes entries lower to, and a scheme for each name a requirement uses that no entry declares. A requirement can add to it, so it is not safe for concurrent use. The zero value is not usable; RegistryOf builds one.
func RegistryOf ¶
RegistryOf returns a Registry holding a copy of declared, the schemes LowerSecuritySchemes lowers, so a scheme a requirement adds reaches the registry and never the caller's map. Such a scheme is placed at the root of c's source.
func (*Registry) Requirements ¶
func (r *Registry) Requirements(c lowering.Ctx, reqs []*soa.SecurityRequirement, base jsontext.Pointer) ([]ir.AuthRequirement, []ir.Diagnostic)
Requirements lowers an OR-of-ANDs security list (docs/ir/auth.md) declared under base: "" at the root, else an operation's own declaration, never its mount. A nil list stays nil, apart from an empty one, which stays []. A non-nil list yields one AuthRequirement per option, diagnosed at base+/security/<index>; an empty option {} means "no auth is one acceptable choice".
A security written as no list arrives nil, beside the loader's report, and so does one under a local tag, with none (#1368). A list of entries naming no option (namesAnOption) yields none, beside the loader's report, and collapses to nil, since [] would read as public.