Documentation
¶
Index ¶
- Constants
- func GenerateBeeToken(secret string, ttl time.Duration) (string, error)
- func GenerateWorkerToken(secret, workerID string, ttl time.Duration) (string, error)
- func JWTMiddleware(jwtSvc *JWTService) gin.HandlerFunc
- type AuthHandler
- type Claims
- type JWTService
- type LoginRateLimiter
- type MCPClaims
- type TokenPair
Constants ¶
const ( TokenTypeBee = "bee" TokenTypeWorker = "worker" )
Variables ¶
This section is empty.
Functions ¶
func GenerateBeeToken ¶ added in v0.0.16
GenerateBeeToken creates a signed JWT for the Bee process.
func GenerateWorkerToken ¶ added in v0.0.16
GenerateWorkerToken creates a signed JWT for a specific Worker.
func JWTMiddleware ¶
func JWTMiddleware(jwtSvc *JWTService) gin.HandlerFunc
Types ¶
type AuthHandler ¶
type AuthHandler struct {
// contains filtered or unexported fields
}
func NewAuthHandler ¶
func NewAuthHandler(username, password string, jwtSvc *JWTService, rateLimiter *LoginRateLimiter) *AuthHandler
func (*AuthHandler) Login ¶
func (h *AuthHandler) Login(c *gin.Context)
func (*AuthHandler) Refresh ¶
func (h *AuthHandler) Refresh(c *gin.Context)
type Claims ¶
type Claims struct {
Type string `json:"type"`
jwt.RegisteredClaims
}
type JWTService ¶
type JWTService struct {
// contains filtered or unexported fields
}
func NewJWTService ¶
func NewJWTService(secret string, accessTTL, refreshTTL time.Duration) *JWTService
func (*JWTService) GenerateAccessToken ¶
func (s *JWTService) GenerateAccessToken() (string, int64, error)
func (*JWTService) GenerateTokenPair ¶
func (s *JWTService) GenerateTokenPair() (*TokenPair, error)
func (*JWTService) ValidateAccessToken ¶
func (s *JWTService) ValidateAccessToken(tokenStr string) error
func (*JWTService) ValidateRefreshToken ¶
func (s *JWTService) ValidateRefreshToken(tokenStr string) error
type LoginRateLimiter ¶
type LoginRateLimiter struct {
// contains filtered or unexported fields
}
func NewLoginRateLimiter ¶
func NewLoginRateLimiter(maxAttempts int, window time.Duration) *LoginRateLimiter
func (*LoginRateLimiter) Allow ¶
func (l *LoginRateLimiter) Allow(ip string) bool
type MCPClaims ¶ added in v0.0.16
type MCPClaims struct {
Type string `json:"type"`
WorkerID string `json:"worker_id,omitempty"`
jwt.RegisteredClaims
}
MCPClaims are the JWT claims embedded in every MCP token.
func ValidateToken ¶ added in v0.0.16
ValidateToken parses and validates a JWT, returning its claims.