token

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package token is used by package ssgrpc for generating and validating HMAC-SHA256 tokens sent as "per RPC credentials".

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTokenExpired = errors.New("token expired")
	ErrBadPayload   = errors.New("payload is missing critical values")

	ErrNoToken        = errors.New("user did not provide a token")
	ErrBadBearerValue = errors.New("user provided an invalid Bearer value")
)

Functions

This section is empty.

Types

type UserToken

type UserToken struct {
	//authenticated user name
	IAM string `json:"iam"`

	//unix epoc expire time
	EXP int64 `json:"exp"`
}

UserToken represents an authenticated user

func GenUserToken

func GenUserToken(user string, expires time.Duration, signingKey []byte) (UserToken, string, error)

GenUserToken will generate an expiring HMAC-SHA256 signed token representing an authenticated user

func ValidateUserToken

func ValidateUserToken(token string, signingKey []byte) (UserToken, error)

ValidateUserToken will validate the token and attempt to unmarshal it's payload into a UserToken.

error is nil if validation succeeded.

Jump to

Keyboard shortcuts

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