auth

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TokenTypeBee    = "bee"
	TokenTypeWorker = "worker"
)

Variables

This section is empty.

Functions

func GenerateBeeToken

func GenerateBeeToken(secret string, ttl time.Duration) (string, error)

GenerateBeeToken creates a signed JWT for the Bee process.

func GenerateWorkerToken

func GenerateWorkerToken(secret, workerID string, ttl time.Duration) (string, error)

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

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

func ValidateToken(tokenStr, secret string) (*MCPClaims, error)

ValidateToken parses and validates a JWT, returning its claims.

type TokenPair

type TokenPair struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
	ExpiresIn    int64  `json:"expires_in"` // seconds until access_token expires
}

Jump to

Keyboard shortcuts

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