base

package
v0.0.0-...-2f69930 Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseConfig

type BaseConfig struct {
	URBAC                bool                `json:"urbac"`
	CheckRight           bool                `json:"check_right"`
	TokenByUrlQuery      bool                `json:"token_by_url_query"`
	TokenByUrlQueryName  string              `json:"token_by_url_query_name"`
	DefaultEnableApp     bool                `json:"default_enable_app"`
	DefaultEnableModule  bool                `json:"default_enable_module"`
	DefaultEnableAction  bool                `json:"default_enable_action"`
	IgnoreAppModuleInfo  []string            `json:"ignore_app_module_info"`
	IgnoreCheckLoginPath map[string][]string `json:"ignore_check_login_path"`
	IgnoreCheckRightPath map[string][]string `json:"ignore_check_right_path"`
	TokenExpireDuration  config.Duration     `json:"token_expire_duration"`
	AllowMultiLogin      bool                `json:"allow_multi_login"`
	AllowMultiLoginNum   int64               `json:"allow_multi_login_num"`
}

type CacheConfig

type CacheConfig struct {
	CacheDefaultExpiration config.Duration `json:"cache_default_expiration"`
	CacheCleanupInterval   config.Duration `json:"cache_cleanup_interval"`
}

type FrontConfig

type FrontConfig struct {
	DefaultRoute    map[string]interface{} `json:"default_route"`
	DefaultHomePath string                 `json:"default_home_path"`
}

type MongodbConfig

type MongodbConfig struct {
	MongoDNS          string `json:"mongo_dns"`
	MongoDatabaseName string `json:"mongo_database_name"`
}

type Service

type Service struct {
	*Config
	*cache.Cache
	M mongodb.Mongoer
}

func NewService

func NewService(c *Config, cc *cache.Cache, m mongodb.Mongoer) *Service

func (*Service) BearerAuth

func (self *Service) BearerAuth(r *http.Request) (string, bool)

func (*Service) CheckRight

func (self *Service) CheckRight(reqPath, httpMethod string, userID primitive.ObjectID) (allow bool)

func (*Service) CreateToken

func (self *Service) CreateToken(ctx context.Context, u model.User, ip, userAgent string, geo [2]float64) (m help.M, err error)

func (*Service) GetApplications

func (self *Service) GetApplications(userID primitive.ObjectID, checkRole bool) help.M

func (*Service) GetClaims

func (self *Service) GetClaims(r *http.Request) (claims *predefined.JWTTokenClaims)

func (*Service) GetPermissionCode

func (self *Service) GetPermissionCode(appsSorted []help.M) []string

func (*Service) GetRoute

func (self *Service) GetRoute(appsSorted []help.M) []help.M

前端通过name进行路由加载,所以name必须唯一,故在添加virtual application时,需要保证同级下的name必须唯一

func (*Service) GetRoutePath

func (self *Service) GetRoutePath(appPath, modulePath, actionPath, method string) string

func (*Service) GetUserInfo

func (self *Service) GetUserInfo(r *http.Request) (u model.User, found bool)

func (*Service) GetValidClaims

func (self *Service) GetValidClaims(r *http.Request) (claims *predefined.JWTTokenClaims, u model.User)

func (*Service) Login

func (self *Service) Login(username, password, ip, userAgent string, geo [2]float64) (m help.M, err error)

func (*Service) Logout

func (self *Service) Logout(r *http.Request)

func (*Service) SortApps

func (self *Service) SortApps(apps map[string]model.Application) []help.M

自然顺序排序,值越大排越后面

Jump to

Keyboard shortcuts

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