auth

package
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: May 17, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package auth implements bearer-token issuance, storage, and verification for v0.1. Tokens are stored in <dataDir>/tokens.json mode 0600. Secrets are shown once on issue; only sha256 hashes are persisted.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

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

Store implements types.Authority backed by a JSON file on disk.

func Open

func Open(dataDir string) (*Store, error)

Open loads tokens.json from dataDir, creating an empty store if missing.

func (*Store) Issue

func (s *Store) Issue(ctx context.Context, peers []string, label string) (string, string, error)

Issue generates a new token authorized for the given peer names. Returns the ID and the plaintext secret; the secret is shown to the user once and never persisted.

func (*Store) List

func (s *Store) List(ctx context.Context) ([]*types.Token, error)

List returns all known tokens (including their hashes; the caller decides what to display).

func (*Store) Revoke

func (s *Store) Revoke(ctx context.Context, tokenID string) error

Revoke removes the token with the given ID and flushes to disk.

func (*Store) Verify

func (s *Store) Verify(ctx context.Context, secret, peerName string) (*types.Token, error)

Verify looks up a token by hashing the supplied secret and confirming it has authority over peerName. Updates LastUsedAt asynchronously.

Jump to

Keyboard shortcuts

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