cmdctx

package
v0.0.0-...-55f89e3 Latest Latest
Warning

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

Go to latest
Published: Dec 16, 2025 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Setup

func Setup(ctx context.Context, cmd *cli.Command) (context.Context, error)

Setup is called before any command runs to initialize shared context.

Types

type CommandContext

type CommandContext struct {
	// Client is the configured OAuth client
	Client *authlib.Client

	// HTTPClient is the HTTP client for making requests
	HTTPClient *http.Client

	// Scope is the requested OAuth scopes
	Scope string

	// Endpoints contains discovered or explicitly configured endpoints
	Endpoints *EndpointConfig

	// DPoPKey is the DPoP proof generator if DPoP is enabled
	DPoPKey authlib.DPoPProofGenerator
}

CommandContext holds shared configuration for all commands.

func Get

func Get(ctx context.Context) (*CommandContext, error)

Get retrieves the CommandContext from the context.

func (*CommandContext) GetAuthorizationServer

func (c *CommandContext) GetAuthorizationServer(requirePAR bool) *authlib.AuthorizationServerConfig

GetAuthorizationServer returns an AuthorizationServer for the given endpoints.

func (*CommandContext) GetRequestOptions

func (c *CommandContext) GetRequestOptions() []authlib.Option

GetRequestOptions returns common request options including HTTP client and DPoP.

func (*CommandContext) RequireAuthorizationEndpoint

func (c *CommandContext) RequireAuthorizationEndpoint() (string, error)

RequireAuthorizationEndpoint returns the authorization endpoint or an error.

func (*CommandContext) RequireClient

func (c *CommandContext) RequireClient() (*authlib.Client, error)

RequireClient returns the configured client or an error if not set.

func (*CommandContext) RequireDeviceEndpoint

func (c *CommandContext) RequireDeviceEndpoint() (string, error)

RequireDeviceEndpoint returns the device authorization endpoint or an error.

func (*CommandContext) RequireHTTPClient

func (c *CommandContext) RequireHTTPClient() (*http.Client, error)

RequireHTTPClient returns the HTTP client or an error if not set.

func (*CommandContext) RequirePAREndpoint

func (c *CommandContext) RequirePAREndpoint() (string, error)

RequirePAREndpoint returns the PAR endpoint or an error.

func (*CommandContext) RequireRegistrationEndpoint

func (c *CommandContext) RequireRegistrationEndpoint() (string, error)

RequireRegistrationEndpoint returns the registration endpoint or an error.

func (*CommandContext) RequireTokenEndpoint

func (c *CommandContext) RequireTokenEndpoint() (string, error)

RequireTokenEndpoint returns the token endpoint or an error.

type EndpointConfig

type EndpointConfig struct {
	AuthorizationEndpoint string
	TokenEndpoint         string
	DeviceEndpoint        string
	PAREndpoint           string
	RegistrationEndpoint  string
}

EndpointConfig holds all endpoint URLs.

Jump to

Keyboard shortcuts

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