auth

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2026 License: MIT Imports: 10 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package auth stores and resolves YouTrack tokens.

Tokens live in the OS keyring under service "ytrack:<host key>". When no keyring is usable, storing fails unless the caller opts into insecure storage, which writes credentials.yml (mode 0600) in the config directory. Nothing silently downgrades from the keyring to the file.

Index

Constants

View Source
const (
	SourceEnv     = "YTRACK_TOKEN"
	SourceKeyring = config.StorageKeyring
	SourceFile    = config.StorageFile
)

Token sources, as reported by Resolve.

Variables

View Source
var ErrNoKeyring = errors.New("no usable OS keyring")

ErrNoKeyring means the OS keyring could not store the token.

Functions

func KeyringService

func KeyringService(hostKey string) string

KeyringService returns the keyring service name for a host key.

func Mask

func Mask(token string) string

Mask hides a token for display, keeping only YouTrack's "perm:"/"perm-" prefix so users can tell a permanent token from something else.

Types

type Store

type Store struct {
	// Dir is the config directory holding the insecure credentials file.
	Dir string
}

Store reads and writes tokens for hosts.

func (Store) Delete

func (s Store) Delete(hostKey string) error

Delete removes hostKey's token from the keyring and the credentials file. A keyring failure is reported only when the file held no copy, since a host saved with --insecure-storage may have no usable keyring at all.

func (Store) Get

func (s Store) Get(hostKey string) (token, source string, err error)

Get returns the stored token for hostKey and its source, or "" if none. A keyring failure other than "not found" (locked keyring, D-Bus error, timeout) is an error unless the credentials file holds the token, so a broken keyring is never reported as "not logged in".

func (Store) Set

func (s Store) Set(hostKey, token string, insecure bool) (string, error)

Set stores token for hostKey and returns where it went (keyring or file). With insecure=false it uses only the keyring and returns an error wrapping ErrNoKeyring when that fails.

Jump to

Keyboard shortcuts

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