token

package
v0.0.0-...-12eefb5 Latest Latest
Warning

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

Go to latest
Published: Feb 12, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package token contains types/methods for handling the signing and parsing of JWT tokens used for authentication.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StreamServerInterceptor

func StreamServerInterceptor(manager *Manager) grpc.StreamServerInterceptor

StreamServerInterceptor returns a grpc.StreamServerInterceptor instance that uses the provided token manager to parse JWT tokens for use by gRPC services.

func ToContext

func ToContext(ctx context.Context, tkn Token) context.Context

ToContext adds the provided token to the context.

func UnaryServerInterceptor

func UnaryServerInterceptor(manager *Manager) grpc.UnaryServerInterceptor

UnaryServerInterceptor returns a grpc.UnaryServerInterceptor instance that uses the provided token manager to parse JWT tokens for use by gRPC services.

Types

type Manager

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

The Manager type is responsible for signing/parsing tokens.

func NewManager

func NewManager(secret string) *Manager

NewManager creates a new Manager instance that uses the provided secret key for signing/parsing tokens.

func (*Manager) New

func (m *Manager) New(user string) (Token, error)

New creates a new Token instance containing user claim data.

func (*Manager) Parse

func (m *Manager) Parse(tkn string) (Token, error)

Parse a token string and return a Token instance containing decoded values.

type Token

type Token struct {
	User string
	// contains filtered or unexported fields
}

The Token type represents a parsed JWT token.

func FromContext

func FromContext(ctx context.Context) Token

FromContext returns the token embedded in the provided context. Returns a zero-value token if one is not present.

func (Token) String

func (t Token) String() string

String returns the JWT token in its raw format.

Jump to

Keyboard shortcuts

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