api

package
v1.4.1 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const AdminCookieName = "pairproxy_admin"

AdminCookieName 管理员 session cookie 名称(供 dashboard 包共享)

Variables

View Source
var DefaultAuthConfig = AuthConfig{
	AccessTokenTTL:  24 * time.Hour,
	RefreshTokenTTL: 7 * 24 * time.Hour,
}

DefaultAuthConfig 默认 TTL 配置

Functions

This section is empty.

Types

type AdminHandler

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

AdminHandler 处理管理员 REST API:用户/分组管理 + 统计查询

func NewAdminHandler

func NewAdminHandler(
	logger *zap.Logger,
	jwtMgr *auth.Manager,
	userRepo *db.UserRepo,
	groupRepo *db.GroupRepo,
	usageRepo *db.UsageRepo,
	adminPasswordHash string,
	tokenTTL time.Duration,
) *AdminHandler

NewAdminHandler 创建 AdminHandler

func (*AdminHandler) RegisterRoutes

func (h *AdminHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes 注册管理员路由到 mux

func (*AdminHandler) RequireAdmin

func (h *AdminHandler) RequireAdmin(next http.Handler) http.Handler

RequireAdmin 中间件:验证 Bearer token 或 cookie 中携带有效的管理员 JWT

type AuthConfig

type AuthConfig struct {
	AccessTokenTTL  time.Duration
	RefreshTokenTTL time.Duration
}

AuthConfig 认证配置

type AuthHandler

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

AuthHandler 处理登录、刷新、登出 HTTP 请求

func NewAuthHandler

func NewAuthHandler(
	logger *zap.Logger,
	jwtMgr *auth.Manager,
	userRepo *db.UserRepo,
	tokenRepo *db.RefreshTokenRepo,
	cfg AuthConfig,
) *AuthHandler

NewAuthHandler 创建 AuthHandler

func (*AuthHandler) RegisterRoutes

func (h *AuthHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes 注册路由到 ServeMux

type ClusterHandler

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

ClusterHandler 处理 sp-2 → sp-1 的内部 API 请求。

func NewClusterHandler

func NewClusterHandler(
	logger *zap.Logger,
	registry *cluster.PeerRegistry,
	usageWriter *db.UsageWriter,
	sharedSecret string,
) *ClusterHandler

NewClusterHandler 创建 ClusterHandler。

func (*ClusterHandler) RegisterRoutes

func (h *ClusterHandler) RegisterRoutes(mux *http.ServeMux)

RegisterRoutes 注册内部 API 路由。 mux: 已有的 *http.ServeMux(或兼容接口)

Jump to

Keyboard shortcuts

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