middlewares

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2024 License: MIT Imports: 37 Imported by: 2

Documentation

Overview

prometheus中间件

Index

Constants

View Source
const (
	LabelValueTenantPlatform = "platform"

	XForwardedUri    = "X-Forwarded-Uri"
	XForwardedMethod = "X-Forwarded-Method"
	XForwardedHost   = "X-Forwarded-Host"
	XForwardedProto  = "X-Forwarded-Proto"
)

Variables

View Source
var (
	URLCACHE_GET         string = "/apis/v1/urlcache/:name"
	URLCACHEALL_GET      string = "/apis/v1/urlcache"
	URLCACHE_FORWARDAUTH string = "/forwardauth"
)
View Source
var (
	IsRancherLogin bool
)
View Source
var NoRoutePath string = "/admin/index"

默认404跳转地址

View Source
var WhilteList []string = []string{
	"URLCACHE_GET", "URLCACHEALL_GET", "URLCACHE_FORWARDAUTH",
}

平台级别白名单列表

Functions

func AdminAuthorizator added in v0.2.2

func AdminAuthorizator(data interface{}, c *gin.Context) bool

role is admin can access

func AllUserAuthorizator added in v0.2.2

func AllUserAuthorizator(data interface{}, c *gin.Context) bool

不限制用户权限

func Cors

func Cors() gin.HandlerFunc

跨域设置

func GetUserClaims added in v0.2.2

func GetUserClaims(username string) ([]Claims, error)

获取用户权限列表

func Login added in v0.2.2

func Login(c *gin.Context)

@Summary 通用接口 @Description 登陆、swagger、注销、404等 @Tags Auth @Param token query string false "token" @Param data body User true "data" @Success 200 {string} string "success" @Security ApiKeyAuth @Router /auth/login [post]

func Logout added in v0.2.2

func Logout(c *gin.Context)

@Summary 通用接口 @Description 登陆、swagger、注销、404等 @Tags Auth @Success 200 {string} string "success" @Security ApiKeyAuth @Router /auth/logout [get]

func NewGinJwtMiddlewares added in v0.2.2

func NewGinJwtMiddlewares(jwta JwtAuthorizator) *jwt.GinJWTMiddleware

根据不同接口的权限规则生成不同权限的jwt中间件

func NoRouteHandler

func NoRouteHandler(c *gin.Context)

404 handler

func PromHandler

func PromHandler(handler http.Handler) gin.HandlerFunc

func RefreshToken added in v0.2.2

func RefreshToken(c *gin.Context)

@Summary 通用接口 @Description 登陆、swagger、注销、404等 @Tags Auth @Success 200 {string} string "success" @Security ApiKeyAuth @Router /auth/refreshtoken [get]

func RegisterHealthMiddleware

func RegisterHealthMiddleware(c *gin.Context)

@Summary 健康检查 @Description 接口健康检查接口 @Tags Health @Success 200 {string} string "success" @Router /health [get]

func RegisterIndex

func RegisterIndex(c *gin.Context)

func RegisterJWT added in v0.2.2

func RegisterJWT(router *gin.Engine)

注册auth

func RegisterNodeExporter added in v0.2.2

func RegisterNodeExporter(router *gin.Engine)

func RegisterPrometheusMiddleware

func RegisterPrometheusMiddleware(router *gin.Engine, isauth bool)

默认prometheus监控+自定义监控

func RegisterPrometheusMiddlewareBasic added in v0.2.5

func RegisterPrometheusMiddlewareBasic(router *gin.Engine, isauth bool)

默认prometheus监控+自定义监控

func RegisterSwaggerMiddleware

func RegisterSwaggerMiddleware(router *gin.Engine)

func RegisterUrlCache

func RegisterUrlCache(router *gin.Engine)

注册UrlCache接口

func TestAuthorizator added in v0.2.2

func TestAuthorizator(data interface{}, c *gin.Context) bool

username is test can access

func VerifyAuth added in v0.2.2

func VerifyAuth(username, password string) (bool, error)

验证用户密码

func VerifyAuthByRancher added in v0.2.2

func VerifyAuthByRancher(username, password string) (string, string, bool)

Types

type IdentityKey added in v0.2.2

type IdentityKey string

type JwtAuthorizator added in v0.2.2

type JwtAuthorizator func(data interface{}, c *gin.Context) bool

接口权限

Jump to

Keyboard shortcuts

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