Documentation
¶
Index ¶
- Constants
- func AdminAuth() func(c *gin.Context)
- func AnonymousRequestBodyLimit() gin.HandlerFunc
- func BodyStorageCleanup() gin.HandlerFunc
- func CORS() gin.HandlerFunc
- func Cache() func(c *gin.Context)
- func ConfigureTrustedProxies(engine *gin.Engine) error
- func CriticalRateLimit() func(c *gin.Context)
- func DecompressRequestMiddleware() gin.HandlerFunc
- func DisableCache() gin.HandlerFunc
- func Distribute() func(c *gin.Context)
- func DownloadRateLimit() func(c *gin.Context)
- func EmailVerificationRateLimit() gin.HandlerFunc
- func GetAuthIdentity(c *gin.Context) (service.AuthIdentity, bool)
- func GetLanguage(c *gin.Context) string
- func GetSessionAuthIdentity(c *gin.Context) (service.AuthIdentity, bool)
- func GlobalAPIRateLimit() func(c *gin.Context)
- func GlobalWebRateLimit() func(c *gin.Context)
- func HeaderNavModuleAuth(module string) gin.HandlerFunc
- func HeaderNavModulePublicOrUserAuth(module string) gin.HandlerFunc
- func I18n() gin.HandlerFunc
- func JimengRequestConvert() func(c *gin.Context)
- func KlingRequestConvert() func(c *gin.Context)
- func ModelRequestRateLimit() func(c *gin.Context)
- func RelayPanicRecover() gin.HandlerFunc
- func RequestId() func(c *gin.Context)
- func RequirePermission(permission authz.Permission) func(c *gin.Context)
- func RequireSecurityProof(c *gin.Context, requiredScope string, allowedMethods []string) bool
- func RootAuth() func(c *gin.Context)
- func RouteTag(tag string) gin.HandlerFunc
- func SearchRateLimit() func(c *gin.Context)
- func SecureVerificationRequired() gin.HandlerFunc
- func SessionCookieOriginGuard() gin.HandlerFunc
- func SetUpLogger(server *gin.Engine)
- func SetupContextForSelectedChannel(c *gin.Context, channel *model.Channel, modelName string) *types.NewAPIError
- func SetupContextForToken(c *gin.Context, token *model.Token, parts ...string) error
- func StatsMiddleware() gin.HandlerFunc
- func SystemPerformanceCheck() gin.HandlerFunc
- func TokenAuth() func(c *gin.Context)
- func TokenAuthReadOnly() func(c *gin.Context)
- func TokenOrUserAuth() func(c *gin.Context)
- func TryUserAuth() func(c *gin.Context)
- func TurnstileCheck() gin.HandlerFunc
- func UploadRateLimit() func(c *gin.Context)
- func UserAuth() func(c *gin.Context)
- func Version() gin.HandlerFunc
- func WssAuth(c *gin.Context)
- type HTTPStats
- type ModelRequest
- type StatsInfo
Constants ¶
const ( EmailVerificationRateLimitMark = "EV" EmailVerificationMaxRequests = 2 // 30秒内最多2次 EmailVerificationDuration = 30 // 30秒时间窗口 )
const ( ModelRequestRateLimitCountMark = "MRRL" ModelRequestRateLimitSuccessCountMark = "MRRLS" )
const RouteTagKey = "route_tag"
Variables ¶
This section is empty.
Functions ¶
func AnonymousRequestBodyLimit ¶
func AnonymousRequestBodyLimit() gin.HandlerFunc
func BodyStorageCleanup ¶
func BodyStorageCleanup() gin.HandlerFunc
BodyStorageCleanup 请求体存储清理中间件 在请求处理完成后自动清理磁盘/内存缓存
func CORS ¶
func CORS() gin.HandlerFunc
func ConfigureTrustedProxies ¶
func CriticalRateLimit ¶
func DecompressRequestMiddleware ¶
func DecompressRequestMiddleware() gin.HandlerFunc
func DisableCache ¶
func DisableCache() gin.HandlerFunc
func Distribute ¶
func DownloadRateLimit ¶
func EmailVerificationRateLimit ¶
func EmailVerificationRateLimit() gin.HandlerFunc
func GetAuthIdentity ¶
func GetAuthIdentity(c *gin.Context) (service.AuthIdentity, bool)
GetAuthIdentity returns a dashboard session identity. PAT-authenticated requests intentionally have no SessionID and cannot manage browser sessions.
func GetLanguage ¶ added in v0.10.8
GetLanguage returns the current language from gin context
func GetSessionAuthIdentity ¶
func GetSessionAuthIdentity(c *gin.Context) (service.AuthIdentity, bool)
GetSessionAuthIdentity returns only identities backed by a live dashboard session. PAT-authenticated requests intentionally fail this check.
func GlobalAPIRateLimit ¶
func GlobalWebRateLimit ¶
func HeaderNavModuleAuth ¶
func HeaderNavModuleAuth(module string) gin.HandlerFunc
func HeaderNavModulePublicOrUserAuth ¶
func HeaderNavModulePublicOrUserAuth(module string) gin.HandlerFunc
func I18n ¶ added in v0.10.8
func I18n() gin.HandlerFunc
I18n middleware detects and sets the language preference for the request
func JimengRequestConvert ¶
func KlingRequestConvert ¶
func ModelRequestRateLimit ¶
ModelRequestRateLimit 模型请求限流中间件
func RelayPanicRecover ¶
func RelayPanicRecover() gin.HandlerFunc
func RequirePermission ¶
func RequirePermission(permission authz.Permission) func(c *gin.Context)
func RequireSecurityProof ¶
RequireSecurityProof validates a proof against the authenticated dashboard session and writes the shared proof error contract on failure.
func RouteTag ¶ added in v0.11.0
func RouteTag(tag string) gin.HandlerFunc
func SearchRateLimit ¶ added in v0.10.8
SearchRateLimit returns a per-user rate limiter for search endpoints. Configurable via SEARCH_RATE_LIMIT_ENABLE / SEARCH_RATE_LIMIT / SEARCH_RATE_LIMIT_DURATION.
func SecureVerificationRequired ¶
func SecureVerificationRequired() gin.HandlerFunc
SecureVerificationRequired protects channel key disclosure. Other sensitive operations validate their narrower proof scopes in their controller.
func SessionCookieOriginGuard ¶
func SessionCookieOriginGuard() gin.HandlerFunc
SessionCookieOriginGuard protects cookie-authenticated refresh/logout endpoints when secure cookie mode is enabled. In insecure local development mode it preserves the legacy behavior and intentionally performs no Origin validation. It never adds CORS response headers and must not be installed on relay routes.
func SetUpLogger ¶
func SetupContextForToken ¶
func SystemPerformanceCheck ¶ added in v0.10.8
func SystemPerformanceCheck() gin.HandlerFunc
SystemPerformanceCheck 检查系统性能中间件
func TokenAuthReadOnly ¶ added in v0.10.8
TokenAuthReadOnly 宽松版本的令牌认证中间件,用于只读查询接口。 只验证令牌 key 是否存在,不检查令牌状态、过期时间和额度。 即使令牌已过期、已耗尽或已禁用,也允许访问。 仍然检查用户是否被封禁。
func TokenOrUserAuth ¶ added in v0.11.0
TokenOrUserAuth allows either session-based user auth or API token auth. Used for endpoints that need to be accessible from both the dashboard and API clients.
func TryUserAuth ¶
func TurnstileCheck ¶
func TurnstileCheck() gin.HandlerFunc
func UploadRateLimit ¶
func Version ¶
func Version() gin.HandlerFunc
Types ¶
type HTTPStats ¶
type HTTPStats struct {
// contains filtered or unexported fields
}
HTTPStats 存储HTTP统计信息
type ModelRequest ¶
Source Files
¶
- audit.go
- auth.go
- auth_origin.go
- body_cleanup.go
- cache.go
- cors.go
- disable-cache.go
- distributor.go
- email-verification-rate-limit.go
- gzip.go
- header_nav.go
- i18n.go
- jimeng_adapter.go
- kling_adapter.go
- logger.go
- model-rate-limit.go
- performance.go
- rate-limit.go
- recover.go
- request-id.go
- request_body_limit.go
- secure_verification.go
- stats.go
- trusted_proxies.go
- turnstile-check.go
- utils.go