jwt

package
v0.1.0-rc.1 Latest Latest
Warning

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

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

Documentation

Overview

Package jwt implements the JavaScript Web Token that can be used for authentication of users.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JWT

type JWT struct {
	// ExpirationInterval of the token.
	ExpirationInterval time.Duration

	// RefreshInterval of the token.
	RefreshInterval time.Duration

	// Secret is used to sign the token.
	Secret []byte

	// AuthType defines the authentication type, i.e., the prefix before the
	// token in authorization header.
	AuthType string
}

JWT defines and creates the token and it's properties.

func (*JWT) GetTokenFromHeader

func (t *JWT) GetTokenFromHeader(ctx *gin.Context) (string, error)

GetTokenFromHeader returns the token from gin Context.

func (*JWT) NewToken

func (t *JWT) NewToken(values interface{}) (string, error)

NewToken creates a new JWT.

func (*JWT) RefreshToken

func (t *JWT) RefreshToken(token string) (refreshToken string, statusCode int, _ error)

RefreshToken returns the refresh token for an expired token.

func (*JWT) VerifyToken

func (t *JWT) VerifyToken(token string) (values interface{}, statusCode int, _ error)

VerifyToken verifies if the token is valid and returns the values for its claims.

Jump to

Keyboard shortcuts

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