jwt

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2026 License: AGPL-3.0 Imports: 7 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package jwt provides JWT token creation and parsing.

It wraps golang-jwt to provide typed claims with user identity fields (UserId, Username, NickName, UUID) and automatic expiration management.

Package jwt provides JWT token creation and parsing.

It wraps golang-jwt to provide typed claims with user identity fields (UserId, Username, NickName, UUID) and automatic expiration management.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Claims

type Claims struct {
	UserId     int       `json:"user_id"`
	Username   string    `json:"username"`
	NickName   string    `json:"nick_name"`
	UUID       uuid.UUID `json:"uuid"`
	BufferTime int64     `json:"buffer_time"`
	jwt.StandardClaims
}

Claims represents the JWT claims with user identity information.

type Token

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

func New

func New(signingKey []byte) *Token

New creates a new Token with the given signing key.

func (*Token) Create

func (j *Token) Create(user Claims, cfg config.JWT) (string, error)

Create generates a signed JWT string from the provided claims and config.

func (*Token) Parse

func (j *Token) Parse(tokenStr string) (*Claims, error)

Parse verifies and extracts claims from a JWT string.

Jump to

Keyboard shortcuts

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