helper

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package helper contains helper functions

Package helper provides helper functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetClaimsFromRefreshToken added in v0.0.4

func GetClaimsFromRefreshToken(refreshToken string) (jwt.MapClaims, error)

GetClaimsFromRefreshToken gets the claims from the refresh token

func GetEchoJWTConfig added in v0.0.4

func GetEchoJWTConfig() echojwt.Config

GetEchoJWTConfig returns the echo JWT config

func GetJWTPublicKey added in v0.0.4

func GetJWTPublicKey() interface{}

GetJWTPublicKey gets the JWT public key

func GetJWTRefreshSigningKey added in v0.0.4

func GetJWTRefreshSigningKey() interface{}

GetJWTRefreshSigningKey gets the JWT refresh signing key

func GetJWTSigningKey added in v0.0.4

func GetJWTSigningKey() interface{}

GetJWTSigningKey gets the JWT signing key

func InArray added in v0.0.6

func InArray(needle string, haystack []string) bool

func StrPtr2Str

func StrPtr2Str(str *string) string

Types

type JwtClaims

type JwtClaims struct {
	UserId      int32  `json:"user_id"`
	Username    string `json:"username"`
	RefreshUUID string `json:"refresh_uuid"` // If 2FA is enabled, this will be false until the user has authenticated with TOTPa
	Scope       string `json:"scope,omitempty"`
	Adm         int32  `json:"adm,omitempty"`
	jwt.RegisteredClaims
}

JwtClaims defines the default claims for JWT

func GetClaimsFromContext

func GetClaimsFromContext(c echo.Context) *JwtClaims

GetClaimsFromContext gets the JWT claims from the echo context

func (*JwtClaims) HasScope added in v0.0.6

func (c *JwtClaims) HasScope(scope string) bool

type TokenDetails

type TokenDetails struct {
	AccessToken  string
	RefreshToken string
	RefreshUUID  string
	AtExpires    *jwt.NumericDate
	RtExpires    *jwt.NumericDate
}

TokenDetails defines the details of the tokens

func GenerateToken

func GenerateToken(claims *JwtClaims, t time.Time) (*TokenDetails, error)

GenerateToken generates a JWT token

type Validator added in v0.0.2

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

Validator is a wrapper around the validator package

func NewValidator added in v0.0.2

func NewValidator() *Validator

NewValidator returns a new Validator

func (*Validator) Validate added in v0.0.2

func (v *Validator) Validate(i interface{}) error

Validate validates a struct based on the tags

Jump to

Keyboard shortcuts

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