auth

package
v0.0.0-...-d33b49b Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsurePaired

func EnsurePaired(ctx context.Context, api PairingAPI, store *TokenStore, cfg *config.Config, logger *zap.SugaredLogger) (token string, firstRun bool, err error)

EnsurePaired ensures the device is paired with the WinDash backend Returns (token, firstRun, error)

func GetMachineID

func GetMachineID() (string, error)

GetMachineID returns a stable unique identifier for this machine

func OpenDashboard

func OpenDashboard(dashboardURL string) error

OpenDashboard opens the WinDash dashboard in the default browser

Types

type MockPairingAPI

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

MockPairingAPI simulates the pairing flow for development/testing

func NewMockPairingAPI

func NewMockPairingAPI(logger *zap.SugaredLogger) *MockPairingAPI

NewMockPairingAPI creates a new mock pairing API

func (*MockPairingAPI) ExchangeCode

func (m *MockPairingAPI) ExchangeCode(ctx context.Context, code string) (string, error)

ExchangeCode simulates polling for device approval

func (*MockPairingAPI) RequestCode

func (m *MockPairingAPI) RequestCode(ctx context.Context) (string, time.Time, error)

RequestCode simulates requesting a device code from the backend

type PairingAPI

type PairingAPI interface {
	RequestCode(ctx context.Context) (code string, expiresAt time.Time, err error)
	ExchangeCode(ctx context.Context, code string) (token string, err error)
}

PairingAPI defines the interface for device pairing operations

type RealPairingAPI

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

RealPairingAPI implements device pairing with the WinDash backend

func NewRealPairingAPI

func NewRealPairingAPI(logger *zap.SugaredLogger, baseURL string) *RealPairingAPI

NewRealPairingAPI creates a new real pairing API client

func (*RealPairingAPI) ExchangeCode

func (r *RealPairingAPI) ExchangeCode(ctx context.Context, code string) (string, error)

ExchangeCode polls the backend for device approval and token

func (*RealPairingAPI) RequestCode

func (r *RealPairingAPI) RequestCode(ctx context.Context) (string, time.Time, error)

RequestCode requests a new device pairing code from the backend

type TokenStore

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

TokenStore manages secure storage of authentication tokens Uses Windows DPAPI via go-keyring

func NewTokenStore

func NewTokenStore(logger *zap.SugaredLogger) *TokenStore

NewTokenStore creates a new token store

func (*TokenStore) DeleteToken

func (s *TokenStore) DeleteToken(deviceID string) error

DeleteToken removes the authentication token from the OS keychain

func (*TokenStore) GetToken

func (s *TokenStore) GetToken(deviceID string) (string, error)

GetToken retrieves the authentication token from the OS keychain

func (*TokenStore) SaveToken

func (s *TokenStore) SaveToken(deviceID, token string) error

SaveToken stores the authentication token securely in the OS keychain

Jump to

Keyboard shortcuts

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