auth

package
v4.0.7 Latest Latest
Warning

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

Go to latest
Published: Feb 11, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTokenNotFound = errors.New("no token found")

ErrTokenNotFound is returned when a token is not found

Functions

This section is empty.

Types

type AuthenticateService

type AuthenticateService interface {
	// Authenticate the user with the given host.
	// The function will return a user name and a token if the authentication is successful.
	Authenticate(ctx context.Context, host string, verify Verify) (string, *Token, error)
}

AuthenticateService is an interface that defines a method for authenticating users.

type DeviceAuthResponse

type DeviceAuthResponse struct {
	// VerificationURI is the URI where the user can verify the authentication.
	VerificationURI string
	// UserCode is the code that the user needs to enter to verify the authentication.
	UserCode string
}

DeviceAuthResponse represents the response from a device authentication request.

type Token

type Token = oauth2.Token

Token represents an authentication token for a repository hosting service

type TokenEntry

type TokenEntry struct {
	Host  string
	Owner string
	Token Token
}

TokenEntry represents a stored token with its host and owner

func (TokenEntry) String

func (t TokenEntry) String() string

type TokenService

type TokenService interface {
	// Get retrieves a token for the specified host and owner
	Get(host, owner string) (Token, error)

	// Set stores a token for the specified host and owner
	Set(host, owner string, token Token) error

	// Delete removes a token for the specified host and owner
	Delete(host, owner string) error

	// Has checks if a token exists for the specified host and owner
	Has(host, owner string) bool

	// Entries returns all stored token entries
	Entries() []TokenEntry

	store.Content
}

TokenService provides access to authentication tokens

func NewTokenService

func NewTokenService() TokenService

type TokenStore

type TokenStore store.Store[TokenService]

TokenStore is a service for saving and loading tokens

type Verify

type Verify func(
	ctx context.Context,
	response DeviceAuthResponse,
) error

Verify is a function type that takes a context and a DeviceAuthResponse

Jump to

Keyboard shortcuts

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