mcp: authorize: load session from the access token (#5591)

This commit is contained in:
Denis Mishin 2025-04-28 16:32:06 -04:00 committed by GitHub
parent 0602f5e00d
commit daaf5b8e30
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 112 additions and 17 deletions

View file

@ -1,6 +1,7 @@
package mcp
import (
"context"
"encoding/json"
"net/http"
"time"
@ -116,3 +117,12 @@ func (srv *Handler) handleAuthorizationCodeToken(w http.ResponseWriter, r *http.
w.WriteHeader(http.StatusOK)
_, _ = w.Write(data)
}
func (srv *Handler) GetSessionIDFromAccessToken(ctx context.Context, accessToken string) (string, bool) {
sessionID, err := DecryptAccessToken(accessToken, srv.cipher)
if err != nil {
log.Ctx(ctx).Error().Err(err).Msg("failed to decrypt access token")
return "", false
}
return sessionID, true
}