auth

package
v0.8.18 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2024 License: MIT Imports: 18 Imported by: 1

Documentation

Index

Constants

View Source
const (
	KeyUser = "currentUser"
)

Variables

This section is empty.

Functions

func Hash added in v0.7.0

func Hash(rawKey string) string

func SignRequest added in v0.1.14

func SignRequest(app, ts, secret string, request []byte) (string, error)

Types

type AuthKey

type AuthKey struct {
	gorm.Model
	UserName   string `gorm:"size:32"`
	ApiKey     string `gorm:"size:64;unique"`
	Owner      string `gorm:"size:64"`
	Role       string `gorm:"size:64"`
	Remark     string `gorm:"size:64"`
	Suspend    bool
	Expiretion *time.Time
}

type AuthService

type AuthService struct {
	Db *gorm.DB

	Keys []string

	HeaderKey string
	// contains filtered or unexported fields
}

func (*AuthService) Auth

func (a *AuthService) Auth(c *gin.Context)

func (*AuthService) CreateUser added in v0.1.7

func (a *AuthService) CreateUser(owner, username, remark, rawKey string) (string, error)

func (*AuthService) Validate added in v0.5.5

func (a *AuthService) Validate(key string) (*AuthKey, bool)

type AuthServiceParam added in v0.0.8

type AuthServiceParam struct {
	dig.In
	DB     *gorm.DB `optional:"true"`
	Logger *zap.Logger
}

type AuthedGroutRoute added in v0.1.6

type AuthedGroutRoute gin.IRoutes

func NewAuthedRouter added in v0.1.6

func NewAuthedRouter(route *gin.Engine, auth *AuthService, logger *zap.Logger, base string, replyCode int) AuthedGroutRoute

func NewDefaultAuthedRouter added in v0.1.6

func NewDefaultAuthedRouter(route *gin.Engine, auth *AuthService, logger *zap.Logger) AuthedGroutRoute

func NewRouterRequiredAuth added in v0.0.8

func NewRouterRequiredAuth(group *gin.RouterGroup, auth *AuthService) AuthedGroutRoute

func NewURIAuthedRouter added in v0.2.1

func NewURIAuthedRouter(route *gin.Engine, auth *AuthService, logger *zap.Logger, uri string) AuthedGroutRoute

type SignService added in v0.1.12

type SignService struct {
	MaxDuration  time.Duration
	KeyTimestamp string
	KeySign      string
	KeyApp       string
	Secrets      map[string]string
	// contains filtered or unexported fields
}

func (*SignService) CheckMaxDuration added in v0.1.12

func (ss *SignService) CheckMaxDuration(c *gin.Context)

func (*SignService) Sign added in v0.1.12

func (ss *SignService) Sign(c *gin.Context)

Jump to

Keyboard shortcuts

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