token

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2024 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package token provides utilities for storing and retrieving data from a local file store.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrTokenExpired is returned from Get when a token is past its expiration.
	ErrTokenExpired = errors.New("expired")

	// ErrNotExist is returned when a token doesn't exist.
	ErrNotExist = errors.New("does not exist")
)

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Name  string
	Valid bool
}

Entry provides metadata about a token stored in the token store

type Store

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

Store can store and retrieve tokens from the local file system.

func NewFileStore

func NewFileStore(root string) *Store

NewFileStore returns a token store that stores tokens on disk relative to a given root. All files will have 0600 permissions. That is, they are only readable by the user putting them on disk.

Paths passed to storage methods must be valid filesystem paths. Paths also must be file paths, not directories.

func (*Store) Get

func (s *Store) Get(path string) (Token, error)

Get retrieves a token from the local file system.

func (*Store) List

func (s *Store) List() ([]Entry, error)

List returns the list of valid tokens stored in the store's root

func (*Store) Put

func (s *Store) Put(path string, token Token) (putErr error)

Put stores a token on the local file system.

type Token

type Token struct {
	Value  []byte    `json:"value"`
	Expiry time.Time `json:"expires"`
}

Token is a generic token stored with an expiration time.

Jump to

Keyboard shortcuts

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