jwt

package
v0.0.0-...-76b470b Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Alg

type Alg string

Alg represent jwt algorithm

const (
	// HS256Key key
	HS256Key = "1234key"

	// HS256 const
	HS256 Alg = "HS256"

	// RS256 const
	RS256 Alg = "RS256"
)

type Claim

type Claim struct {
	Issuer    string
	Audience  string
	Subject   string
	ExpiredAt int64
	IssuedAt  int64
	User      struct {
		ID       string
		FullName string
		Email    string
	}
	Alg Alg
}

Claim model

type JWT

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

JWT implementation from JwtService

func NewJWT

func NewJWT(publicKey *rsa.PublicKey, privateKey *rsa.PrivateKey) *JWT

NewJWT constructor

func (*JWT) Generate

func (r *JWT) Generate(ctx context.Context, payload *Claim, expired time.Duration) shared.Result

Generate token

func (*JWT) Validate

func (r *JWT) Validate(ctx context.Context, tokenString string) shared.Result

Validate token

type JwtService

type JwtService interface {
	Generate(ctx context.Context, payload *Claim, expired time.Duration) shared.Result
	Validate(ctx context.Context, token string) shared.Result
}

JwtService represent jwt service

Jump to

Keyboard shortcuts

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