auth

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Mar 2, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

internal/auth/bitbucket.go

internal/auth/credentials.go

internal/auth/github.go

internal/auth/gitlab.go

Index

Constants

This section is empty.

Variables

View Source
var ErrNoCredentials = errors.New("no credentials found")

Functions

func DefaultStorePath

func DefaultStorePath() string

func GhCLIToken added in v0.4.0

func GhCLIToken() (string, bool)

GhCLIToken attempts to get a GitHub token from the gh CLI tool. Returns the token and true if successful, or empty string and false otherwise.

func GlabCLIToken added in v0.8.0

func GlabCLIToken() (string, bool)

GlabCLIToken attempts to get a GitLab token from the glab CLI tool. Returns the token and true if successful, or empty string and false otherwise.

Types

type BitbucketOAuth

type BitbucketOAuth struct {
	ClientID     string
	ClientSecret string
	TokenURL     string // overridable for testing
}

func (*BitbucketOAuth) ExchangeCode

func (b *BitbucketOAuth) ExchangeCode(ctx context.Context, code string) (Credentials, error)

func (*BitbucketOAuth) Login

func (b *BitbucketOAuth) Login(ctx context.Context) (Credentials, error)

func (*BitbucketOAuth) RefreshToken

func (b *BitbucketOAuth) RefreshToken(ctx context.Context, refreshToken string) (Credentials, error)

type Credentials

type Credentials struct {
	AccessToken  string    `json:"access_token"`
	RefreshToken string    `json:"refresh_token,omitempty"`
	ExpiresAt    time.Time `json:"expires_at,omitempty"`
	Username     string    `json:"username,omitempty"`
}

func (Credentials) Expired

func (c Credentials) Expired() bool

type FileStore

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

func NewFileStore

func NewFileStore(path string) *FileStore

func (*FileStore) Load

func (s *FileStore) Load(provider string) (Credentials, error)

func (*FileStore) LoadWithEnv

func (s *FileStore) LoadWithEnv(provider string) (Credentials, error)

func (*FileStore) Save

func (s *FileStore) Save(provider string, cred Credentials) error

type GitHubOAuth

type GitHubOAuth struct {
	ClientID    string
	DeviceURL   string // overridable for testing
	TokenURL    string // overridable for testing
	OpenBrowser bool
}

func (*GitHubOAuth) Login

func (g *GitHubOAuth) Login(ctx context.Context) (Credentials, error)

Jump to

Keyboard shortcuts

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