Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrNotFound = errors.New("credentials not found")
ErrNotFound is returned by AuthStore.Load when no credentials are stored.
Functions ¶
func Commands ¶
Commands builds the "auth" parent command with subcommands based on the capabilities of the configured provider.
func DecorateContext ¶
DecorateContext calls the configured AuthDecorator and appends the resulting key-value pairs to the outgoing gRPC metadata on the context. Returns the original context unchanged if there is no decorator, on error, or when the decorator returns an empty map (lenient — allows unauthenticated commands to proceed).
Types ¶
type AuthDecorator ¶
type AuthDecorator interface {
Decorate(ctx context.Context, store AuthStore) (map[string]string, error)
}
AuthDecorator decorates outgoing gRPC requests with authentication metadata.
type AuthStore ¶
type AuthStore interface {
Save(ctx context.Context, token []byte) error
Load(ctx context.Context) ([]byte, error)
Delete(ctx context.Context) error
}
AuthStore provides credential persistence for authentication tokens.
type Config ¶
type Config struct {
Provider LoginProvider
Store AuthStore
Decorator AuthDecorator
}
Config holds the auth configuration assembled from a LoginProvider and options.
type InteractiveLoginProvider ¶
type InteractiveLoginProvider interface {
LoginProvider
LoginInteractive(ctx context.Context, in io.Reader, out io.Writer, store AuthStore) error
}
InteractiveLoginProvider extends LoginProvider with interactive prompting support.
type KeychainStore ¶
type KeychainStore struct {
// contains filtered or unexported fields
}
KeychainStore persists credentials using the OS keychain (macOS Keychain, Windows Credential Manager, Linux Secret Service).
func NewKeychainStore ¶
func NewKeychainStore(appName string) *KeychainStore
NewKeychainStore creates a KeychainStore that stores credentials under the given application name as the keychain service name.
func (*KeychainStore) Delete ¶
func (s *KeychainStore) Delete(_ context.Context) error
Delete removes the stored credential from the keychain. Returns ErrNotFound if no credential is stored.
type LoginProvider ¶
type LoginProvider interface {
Flags() []cli.Flag
Login(ctx context.Context, cmd *cli.Command, store AuthStore) error
}
LoginProvider handles flag-based authentication login.
type LogoutProvider ¶
LogoutProvider adds logout capability to the auth command suite.
type Option ¶
type Option func(*Config)
Option configures an auth Config.
func WithDecorator ¶
func WithDecorator(decorator AuthDecorator) Option
WithDecorator sets an AuthDecorator for decorating outgoing gRPC requests.