accesstoken

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2018 License: AGPL-3.0 Imports: 10 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")
	// ErrNoMatchID is returned when Delete is called on nonexisting ID.
	ErrNoMatchID = errors.New("nonexisting access token ID")
)

Functions

This section is empty.

Types

type CredentialStore

type CredentialStore struct {
	DB dbm.DB
}

CredentialStore store user access credential.

func NewStore added in v0.2.0

func NewStore(db dbm.DB) *CredentialStore

NewStore creates and returns a new Store object.

func (*CredentialStore) Check added in v0.2.0

func (cs *CredentialStore) 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 (*CredentialStore) Create added in v0.2.0

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

Create generates a new access token with the given ID.

func (*CredentialStore) Delete added in v0.2.0

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

Delete deletes an access token by id.

func (*CredentialStore) List added in v0.2.0

func (cs *CredentialStore) List(ctx context.Context) ([]*Token, error)

List lists all access tokens.

type Token

type Token struct {
	ID      string    `json:"id"`
	Token   string    `json:"token,omitempty"`
	Type    string    `json:"type,omitempty"`
	Created time.Time `json:"created_at"`
}

Token describe the access token.

Jump to

Keyboard shortcuts

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