accesstoken

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2017 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package accesstoken provides storage and validation of Chain Core credentials.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrBadID is returned when Create is called on an invalid id string.
	ErrBadID = errors.New("invalid id")
	// ErrDuplicateID is returned when Create is called on an existing ID.
	ErrDuplicateID = errors.New("duplicate access token ID")
	// ErrBadType is returned when Create is called with a bad type.
	ErrBadType = errors.New("type must be client or network")
)

Functions

This section is empty.

Types

type CredentialStore

type CredentialStore struct {
}

type Token

type Token struct {
	ID      string    `json:"id"`
	Token   string    `json:"token,omitempty"`
	Type    string    `json:"type,omitempty"` // deprecated in 1.2
	Created time.Time `json:"created_at"`
	// contains filtered or unexported fields
}

func (*Token) Check

func (cs *Token) Check(ctx context.Context, id string, secret []byte) (bool, error)

Check returns whether or not an id-secret pair is a valid access token.

func (*Token) Create

func (cs *Token) Create(ctx context.Context, id, typ string) (*Token, error)

Create generates a new access token with the given ID.

func (*Token) Delete

func (cs *Token) Delete(ctx context.Context, id string) error

Delete deletes an access token by id.

func (*Token) Exists

func (cs *Token) Exists(ctx context.Context, id string) bool

Exists returns whether an id is part of a valid access token. It does not validate a secret.

func (*Token) List

func (cs *Token) List(ctx context.Context, typ, after string, limit int) ([]*Token, string, error)

List lists all access tokens.

Jump to

Keyboard shortcuts

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