mcp: handle and pass upstream oauth2 tokens (#5595)

This commit is contained in:
Denis Mishin 2025-05-01 12:42:31 -04:00 committed by GitHub
parent 561b6040b5
commit 9d66f762e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 337 additions and 80 deletions

View file

@ -4,15 +4,13 @@ import (
"fmt"
"net/http"
"github.com/bufbuild/protovalidate-go"
"github.com/pomerium/pomerium/internal/oauth21/gen"
)
// ParseCodeGrantAuthorizeRequest parses the authorization request for the code grant flow.
// see https://datatracker.ietf.org/doc/html/draft-ietf-oauth-v2-1-12#section-4.1.1
// scopes are ignored
func ParseCodeGrantAuthorizeRequest(r *http.Request, sessionID string) (*gen.AuthorizationRequest, error) {
func ParseCodeGrantAuthorizeRequest(r *http.Request) (*gen.AuthorizationRequest, error) {
if err := r.ParseForm(); err != nil {
return nil, fmt.Errorf("failed to parse form: %w", err)
}
@ -24,11 +22,6 @@ func ParseCodeGrantAuthorizeRequest(r *http.Request, sessionID string) (*gen.Aut
State: optionalFormParam(r, "state"),
CodeChallenge: r.Form.Get("code_challenge"),
CodeChallengeMethod: optionalFormParam(r, "code_challenge_method"),
SessionId: sessionID,
}
if err := protovalidate.Validate(v); err != nil {
return nil, fmt.Errorf("invalid request: %w", err)
}
return v, nil