jwt

package
v0.0.0-...-0ddd045 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package jwt provides utilities to genearte and validate JWT credentials

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrUsernameEmpty indicates that username is empty in claims
	ErrUsernameEmpty = errors.New("Username cannot be empty")
)

Functions

This section is empty.

Types

type Claims

type Claims struct {
	Username   string            `json:"username"`
	Privileges models.Privileges `json:"privileges"`
	StandardClaims
}

Claims is a custom claims struct

func (Claims) Valid

func (c Claims) Valid() error

Valid returns wether the claims are valid

type JWT

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

JWT wraps a JWT token, it's key and claims

func New

func New(key string, c *Claims) *JWT

New returns a new JWT instance

func Parse

func Parse(input, key string, c Claims) (*JWT, error)

Parse parses the input token and returns a new JWT instance or an error

func (*JWT) Claims

func (j *JWT) Claims() Claims

Claims returns the cliams of the token

func (*JWT) Sign

func (j *JWT) Sign() (string, error)

Sign signs the token and returns the token as a string or an error

type StandardClaims

type StandardClaims jwt.StandardClaims

StandardClaims is a wrapper for jwt.StandardClaims

Jump to

Keyboard shortcuts

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