mcp: pass access token to the upstream (#5593)

This commit is contained in:
Denis Mishin 2025-04-29 12:13:18 -04:00 committed by GitHub
parent b9e3a5d301
commit 5b024a8ada
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
15 changed files with 774 additions and 719 deletions

View file

@ -1,7 +1,6 @@
package mcp
import (
"context"
"encoding/json"
"net/http"
"time"
@ -88,7 +87,7 @@ func (srv *Handler) handleAuthorizationCodeToken(w http.ResponseWriter, r *http.
return
}
accessToken, err := CreateAccessToken(session, srv.cipher)
accessToken, err := srv.CreateAccessTokenForSession(session.Id, session.ExpiresAt.AsTime())
if err != nil {
http.Error(w, "internal error", http.StatusInternalServerError)
return
@ -117,12 +116,3 @@ 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
}