midware

package
v0.0.0-...-e9de818 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2024 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JWTExpireMinute = 720
)

Variables

View Source
var APITokenSecret = []byte(infra.Secret)

Functions

func AKSKAuth

func AKSKAuth() gin.HandlerFunc

func CheckUser

func CheckUser(username, password string) (*login.User, error)

func CreateToken

func CreateToken(payload jwt.Claims, secret []byte) (string, error)

func GenPassword

func GenPassword(password, salt string) string

func GeneralJwtToken

func GeneralJwtToken(userName string) (string, error)

func GeneralSession

func GeneralSession() string

func HubAuthRequestOption

func HubAuthRequestOption() *grequests.RequestOptions

func InnerAuthRequestOption

func InnerAuthRequestOption() *grequests.RequestOptions

func Metrics

func Metrics() gin.HandlerFunc

func RBACAuth

func RBACAuth() gin.HandlerFunc

func RuleIDSort

func RuleIDSort(one MetaRule, other MetaRule) bool

func SdAuthRequestOption

func SdAuthRequestOption() *grequests.RequestOptions

func SvrAuthRequestOption

func SvrAuthRequestOption() *grequests.RequestOptions

func TokenAuth

func TokenAuth() gin.HandlerFunc

func VerifyToken

func VerifyToken(tokenString string, secret []byte) (*jwt.MapClaims, error)

Types

type AcController

type AcController struct {
	// contains filtered or unexported fields
}
var ACWorker *AcController

func NewAcController

func NewAcController(fileName string) (*AcController, error)

func (*AcController) IsRequestGranted

func (a *AcController) IsRequestGranted(path, role string) bool

type AcRule

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

func NewAcRule

func NewAcRule(rule *MetaRule) *AcRule

func (*AcRule) MatchPath

func (c *AcRule) MatchPath(path string) bool

func (*AcRule) MatchRole

func (c *AcRule) MatchRole(role string) bool

type AuthClaims

type AuthClaims struct {
	Username string `json:"username"`
	jwt.StandardClaims
}

type MetaRule

type MetaRule struct {
	ID              int      `json:"id" yaml:"id"`
	Desc            string   `json:"desc" yaml:"desc"`
	PathEqual       []string `json:"path_equal" yaml:"path_equal"`
	PathPre         []string `json:"path_pre" yaml:"path_pre"`
	PathRegex       []string `json:"path_regex" yaml:"path_regex"`
	AuthorizedRoles []int    `json:"authorized_roles" yaml:"authorized_roles"`
	AllowAnyone     bool     `json:"allow_anyone" yaml:"allow_anyone"`
}

Jump to

Keyboard shortcuts

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