flags

package
v0.13.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package flags declares the command-line flags that configure a service's authenticators once, so every command reads the same ones and resolves them alike.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Authenticators

type Authenticators struct {
	// contains filtered or unexported fields
}

Authenticators is the chain the flags resolve to and what a command says about it: nothing is configured when the chain is empty.

func (Authenticators) Chain

func (a Authenticators) Chain() guard.Chain

Chain is the authenticators in the order a request is asked of them; nil when none is configured, which a service serves open where it may.

func (Authenticators) Configured

func (a Authenticators) Configured() bool

Configured reports whether any authenticator guards the service.

func (Authenticators) Reload

func (a Authenticators) Reload() error

Reload has every authenticator that reads a file read it again, as on SIGHUP; the errors are joined, each file that fails keeping what it held.

func (Authenticators) String

func (a Authenticators) String() string

String names what guards the service for a startup line: the kinds configured, comma-separated, or none.

func (Authenticators) TokenText

func (a Authenticators) TokenText() string

TokenText is the static token as it was given, for a command that prints its configuration; empty without one.

type Options

type Options struct {
	// TokenFile is -token-file, the file holding the static bearer token.
	TokenFile string
	// Token is -token, the static bearer token itself.
	Token string
	// APIKeys is -api-keys, the file of hashed API key records.
	APIKeys string
	// Logger hears the API key store's reloads; nil is the default logger.
	Logger *slog.Logger
	// OIDCIssuer is -oidc-issuer, the OpenID provider whose access tokens are accepted.
	OIDCIssuer string
	// OIDCAudience is -oidc-audience, what a token's aud must name; "" is Resource.
	OIDCAudience string
	// OIDCScopeClaim is -oidc-scope-claim, the claim scopes are read from.
	OIDCScopeClaim string
	// OIDCIntrospect is -oidc-introspect, the RFC 7662 endpoint for opaque tokens.
	OIDCIntrospect string
	// OIDCClientFile is -oidc-client-file, the introspection client's credential.
	OIDCClientFile string
	// Resource is the URL the command serves its protected resource at (RFC
	// 8707), the audience when -oidc-audience is not given; the command sets it.
	Resource string
}

Options is what the authenticator flags resolve to; the zero value configures no authenticator.

func Register

func Register(fs *flag.FlagSet, env string) *Options

Register declares the authenticator flags on fs; env is the variable the command reads a static token from when no flag names one.

func (*Options) Given

func (o *Options) Given() string

Given names the first authenticator flag given, so a transport they are not for can refuse it by name; empty when none is.

func (*Options) Resolve

func (o *Options) Resolve(env string, scopes ...string) (Authenticators, error)

Resolve reads the credentials the flags (or env) name into the chain a service verifies through: each kind ahead of the static token, whose scopes these are.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL