jwt_tool

package
v0.0.0-...-c2276db Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Issuer            = "auth-service"
	Audience          = "auth-service"
	UserClaimsKey key = iota
	TokenLength   int = 54 // To ensure the base64-encoded string is ≤ 72 bytes supported by bcrypt
)

Variables

This section is empty.

Functions

This section is empty.

Types

type ITokenGenerator

type ITokenGenerator interface {
	GenerateAccessToken(
		user *model.User,
		deviceId *uuid.UUID,
		installationId *uuid.UUID,
		jwtSecretKey string,
	) (string, error)
	GenerateRefreshToken() (string, time.Time, error)
}

type JwtAuthInfo

type JwtAuthInfo struct {
	UserInfo       *JwtUserInfo
	DeviceId       *uuid.UUID
	InstallationId *uuid.UUID
}

func ExtractAuthInfo

func ExtractAuthInfo(ctx context.Context) *JwtAuthInfo

type JwtUserInfo

type JwtUserInfo struct {
	Id    *uuid.UUID
	Role  JwtUserRole
	Email string
}

type JwtUserRole

type JwtUserRole string

type TokenGenerator

type TokenGenerator struct{}

func (*TokenGenerator) GenerateAccessToken

func (gen *TokenGenerator) GenerateAccessToken(
	user *model.User,
	deviceId *uuid.UUID,
	installationId *uuid.UUID,
	jwtSecretKey string,
) (string, error)

func (*TokenGenerator) GenerateRefreshToken

func (gen *TokenGenerator) GenerateRefreshToken() (string, time.Time, error)

GenerateToken generates a base64 encoded securely random string

Jump to

Keyboard shortcuts

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