jsonweb

package
v2.7.2 Latest Latest
Warning

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

Go to latest
Published: Oct 12, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrKeyNotFound should be returned by a KeyStore when
	// a key cannot be located for the provided key ID
	ErrKeyNotFound = errors.New("key not found")

	// EmptyKeyStore is a KeyStore implementation which contains no keys
	EmptyKeyStore = KeyStoreFunc(func(string) ([]byte, error) {
		return nil, ErrKeyNotFound
	})
)

Functions

func IsMalformedError

func IsMalformedError(err error) bool

IsMalformedError returns true if the error returned represents a jwt malformed token error

Types

type KeyStore

type KeyStore interface {
	Key(string) ([]byte, error)
}

KeyStore is a type which holds a set of keys accessed via an id

type KeyStoreFunc

type KeyStoreFunc func(string) ([]byte, error)

KeyStoreFunc is a function which can be used as a KeyStore

func (KeyStoreFunc) Key

func (k KeyStoreFunc) Key(v string) ([]byte, error)

Key delegates to the receiver KeyStoreFunc

type Token

type Token struct {
	jwt.StandardClaims
	// KeyID is the identifier of the key used to sign the token
	KeyID string `json:"kid"`
	// Permissions is the set of authorized permissions for the token
	Permissions []influxdb.Permission `json:"permissions"`
	// UserID for the token
	UserID string `json:"uid,omitempty"`
}

Token is a structure which is serialized as a json web token It contains the necessary claims required to authorize

func (*Token) EphemeralAuth

func (t *Token) EphemeralAuth(orgID platform.ID) *influxdb.Authorization

EphemeralAuth creates a influxdb Auth form a jwt token

func (*Token) GetUserID

func (t *Token) GetUserID() platform.ID

GetUserID returns an invalid id as tokens are generated with permissions rather than for or by a particular user

func (*Token) Identifier

func (t *Token) Identifier() platform.ID

Identifier returns the identifier for this Token as found in the standard claims

func (*Token) Kind

func (t *Token) Kind() string

Kind returns the string "jwt" which is used for auditing

func (*Token) PermissionSet

func (t *Token) PermissionSet() (influxdb.PermissionSet, error)

PermissionSet returns the set of permissions associated with the token.

type TokenParser

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

TokenParser is a type which can parse and validate tokens

func NewTokenParser

func NewTokenParser(keyStore KeyStore) *TokenParser

NewTokenParser returns a configured token parser used to parse Token types from strings

func (*TokenParser) Parse

func (t *TokenParser) Parse(v string) (*Token, error)

Parse takes a string then parses and validates it as a jwt based on the key described within the token

Jump to

Keyboard shortcuts

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