Documentation
¶
Overview ¶
Package session provides JWT-based session ID generation and validation
Index ¶
- Constants
- func WithRedisClient(client *redis.Client) func(c *Cache)
- type Cache
- func (c *Cache) AddSession(ctx context.Context, key, mcpServerID, mcpSession string) (bool, error)
- func (c *Cache) DeleteSessions(ctx context.Context, key ...string) error
- func (c *Cache) GetClientElicitation(ctx context.Context, gatewaySessionID string) (bool, error)
- func (c *Cache) GetSession(ctx context.Context, key string) (map[string]string, error)
- func (c *Cache) KeyExists(ctx context.Context, key string) (bool, error)
- func (c *Cache) RemoveServerSession(ctx context.Context, key, mcpServerID string) error
- func (c *Cache) SetClientElicitation(ctx context.Context, gatewaySessionID string) error
- type Claims
- type Deleter
- type JWTManager
Constants ¶
const ( // DefaultSessionDuration is the default duration for session JWTs DefaultSessionDuration = 24 * time.Hour )
Variables ¶
This section is empty.
Functions ¶
func WithRedisClient ¶ added in v0.6.0
WithRedisClient configures the cache to use an existing redis client
Types ¶
type Cache ¶
type Cache struct {
// contains filtered or unexported fields
}
Cache implements a cache
func NewCache ¶
NewCache returns a new cache. Pass WithRedisClient to use an external redis store; otherwise an in-memory cache is returned.
func (*Cache) AddSession ¶
AddSession will add a session under the key. If the key exists it will append that session
func (*Cache) DeleteSessions ¶
DeleteSessions deletes sessions and associated metadata from the cache
func (*Cache) GetClientElicitation ¶ added in v0.6.0
GetClientElicitation returns whether the client for this gateway session supports elicitation
func (*Cache) GetSession ¶
GetSession returns a session from the cache
func (*Cache) RemoveServerSession ¶
RemoveServerSession remove specific server session form cache
type Claims ¶
type Claims struct {
jwt.RegisteredClaims
}
Claims represents the claims in a session JWT
type JWTManager ¶
type JWTManager struct {
// contains filtered or unexported fields
}
JWTManager handles JWT generation and validation for session IDs
func NewJWTManager ¶
func NewJWTManager(signingKey string, sessionLength int64, logger *slog.Logger, sessionHandler Deleter) (*JWTManager, error)
NewJWTManager creates a new JWT manager with the provided signing key
func (*JWTManager) Generate ¶
func (m *JWTManager) Generate() string
Generate returns a session id JWT to fullfil SessionIdManager interface
func (*JWTManager) GetExpiresIn ¶
func (m *JWTManager) GetExpiresIn(tokenValue string) (time.Time, error)
GetExpiresIn returns the time a token will expire