auth

package
v0.7.17 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(gcm cipher.AEAD, encoded string) ([]byte, error)

Decrypt decodes base64 input then decrypts AES-256-GCM (iv || ciphertext || tag).

func DeriveSharedKey

func DeriveSharedKey(privateKey *ecdh.PrivateKey, peerPublicKeyB64 string) (cipher.AEAD, error)

DeriveSharedKey performs X25519 ECDH + HKDF to produce an AES-256-GCM key.

func Encrypt

func Encrypt(gcm cipher.AEAD, plaintext []byte) (string, error)

Encrypt encrypts plaintext with AES-256-GCM and returns base64(iv || ciphertext || tag).

func EnsureKeyPair

func EnsureKeyPair(dir string) (string, error)

EnsureKeyPair loads or generates an X25519 keypair. Returns the base64-encoded public key. Private key is stored in dir/wing_key.

func LoadPrivateKey

func LoadPrivateKey(dir string) (*ecdh.PrivateKey, error)

LoadPrivateKey loads the X25519 private key from disk.

Types

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURL string `json:"verification_url"`
	ExpiresIn       int    `json:"expires_in"`
	Interval        int    `json:"interval"`
}

func RequestDeviceCode

func RequestDeviceCode(baseURL, machineID string, publicKey ...string) (*DeviceCodeResponse, error)

type DeviceToken

type DeviceToken struct {
	Token     string `json:"token" yaml:"device_token"`
	ExpiresAt int64  `json:"expires_at" yaml:"expires_at"`
	IssuedAt  int64  `json:"issued_at" yaml:"issued_at"`
	DeviceID  string `json:"device_id" yaml:"device_id"`
	PublicKey string `json:"public_key,omitempty" yaml:"public_key,omitempty"`
}

type TokenResponse

type TokenResponse struct {
	Token     string `json:"token"`
	ExpiresAt int64  `json:"expires_at"`
	Error     string `json:"error,omitempty"`
}

func PollForToken

func PollForToken(ctx context.Context, baseURL, deviceCode string, interval int) (*TokenResponse, error)

func RefreshToken

func RefreshToken(baseURL string, token DeviceToken) (*TokenResponse, error)

type TokenStore

type TokenStore struct {
	Dir string
}

func NewTokenStore

func NewTokenStore(dir string) *TokenStore

func (*TokenStore) Delete

func (s *TokenStore) Delete() error

func (*TokenStore) IsValid

func (s *TokenStore) IsValid(token *DeviceToken) bool

func (*TokenStore) Load

func (s *TokenStore) Load() (*DeviceToken, error)

func (*TokenStore) Save

func (s *TokenStore) Save(token *DeviceToken) error

Jump to

Keyboard shortcuts

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