gjwt

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2020 License: MIT Imports: 4 Imported by: 0

README

gjwt

godoc tests sec coverage go-report license

Handles authentication using JWTs.

Types
  • JWTAuth: Does JWT authentication. Contains the secret key used to sign JWTs as well as the expiration time.
Methods
  • JWTAuth.Create: Creates a JWT token with the provided metadata.
  • JWTAuth.Extract: Extracts metadata from the given JWT token.
Testing

make test

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWTAuth

type JWTAuth struct {
	Secret string
}

JWTAuth handles encoding and decoding JWT tokens.

func (*JWTAuth) Create

func (auth *JWTAuth) Create(meta interface{}, issuer string, expirationInMinutes uint) (string, error)

Create creates a JWT token for a given user ID.

func (*JWTAuth) Extract

func (auth *JWTAuth) Extract(rawToken string) (interface{}, error)

Extract will take a raw token and extract the value.

func (*JWTAuth) ExtractFromHeader

func (auth *JWTAuth) ExtractFromHeader(tokenHeader string) (interface{}, error)

ExtractFromHeader returns the encoded object from the header.

Jump to

Keyboard shortcuts

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