auth

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	UnauthorizedMsg = "unauthorized"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

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

func NewAuth

func NewAuth(secret string, sessionDurationDays int) *Auth

func (*Auth) GenerateToken

func (auth *Auth) GenerateToken(user entities.User, role entities.Role) string

func (*Auth) ValidateToken

func (auth *Auth) ValidateToken(role entities.Role) gin.HandlerFunc

ValidateToken validates a token for a specific role and sets ID and Email in context

type AuthI added in v1.2.0

type AuthI interface {
	GenerateToken(user entities.User, role entities.Role) string
	ValidateToken(role entities.Role) gin.HandlerFunc
}

type CustomClaims added in v1.1.0

type CustomClaims struct {
	Username string        `json:"username"`
	Email    string        `json:"email"`
	Role     entities.Role `json:"role"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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