Documentation
¶
Overview ¶
Package oauthstore persists opaque OAuth state without placing credentials in the filesystem in plaintext. The native keyring contains only a random master key; every record is independently authenticated and encrypted.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // Callers should present a user action rather than silently persisting // credentials elsewhere. ErrUnavailable = errors.New("OAuth credential store unavailable") // ErrCorrupt means a record was present but cannot safely be decoded or // authenticated with the current master key. ErrCorrupt = errors.New("OAuth credential store record is corrupt") // ErrUnsafeState means a required private state path is a symlink, is not // owned by this user, or has insecure permissions. ErrUnsafeState = errors.New("unsafe OAuth credential state") // ErrStale means a caller tried to refresh a credential generation that // has since been replaced or deleted. ErrStale = errors.New("OAuth credential generation is stale") // ErrAuthorizationLocked means another process is already completing an // authorization flow for the same opaque credential identity. ErrAuthorizationLocked = errors.New("OAuth authorization is already in progress") )
Functions ¶
This section is empty.
Types ¶
type Keyring ¶
type Keyring interface {
Get(service, account string) (string, error)
Set(service, account, secret string) error
Delete(service, account string) error
}
Keyring is the small subset of the native keyring used by Store. Supplying one through Options makes persistence tests independent of the host desktop keyring.
type Options ¶
Options controls Store dependencies. StateDir is the private Wirecmd state directory (not the OAuth subdirectory); the default follows XDG_STATE_HOME and then ~/.local/state. Random defaults to crypto/rand.Reader.
type Record ¶
type Record struct {
Generation string `json:"generation"`
Payload json.RawMessage `json:"payload"`
}
Record is an encrypted OAuth state payload. Generation is stable across saves when supplied by the caller; Save creates one for a new record. Payload is deliberately SDK-agnostic JSON owned by the OAuth execution layer, which prevents this package from becoming an OAuth protocol shim.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store provides serialized encrypted records. The identity passed to methods must be a stable, canonical byte encoding of the caller's credential scope. It is never used as a pathname or written to disk.
func New ¶
New opens a store using the standard Wirecmd state location. It performs no keyring or filesystem access until an operation is requested.
func (*Store) Delete ¶
Delete removes a stored record. found is false when no matching record is present, including when Wirecmd has never created a master key.
func (*Store) Load ¶
Load retrieves one record. found is false only when no matching credentials are stored; unavailable, unsafe, and corrupted states always return an error so callers never mistake them for logged-out state.
func (*Store) LockAuthorization ¶
LockAuthorization acquires a non-blocking, cross-process lease for one credential identity. The returned release function must be called when the browser flow ends. The opaque lock filename reveals neither the endpoint nor registration inputs.