mirror of
https://github.com/pomerium/pomerium.git
synced 2025-06-22 20:48:10 +02:00
## Summary Fixes to MCP code registration and token requests. 1. ease some requirements on fields that are RECOMMENDED 2. fill in defaults 3. store both request and response in the client registration 4. check client secret in the /token request ## Related issues - Fixes https://linear.app/pomerium/issue/ENG-2462/mcp-ignore-unknown-grant-types-in-the-client-registration - Fixes https://linear.app/pomerium/issue/ENG-2461/mcp-support-client-secret-in-dynamic-client-registration ## User Explanation <!-- How would you explain this change to the user? If this change doesn't create any user-facing changes, you can leave this blank. If filled out, add the `docs` label --> ## Checklist - [x] reference any related issues - [x] updated unit tests - [x] add appropriate label (`enhancement`, `bug`, `breaking`, `dependencies`, `ci`) - [ ] ready for review
28 lines
893 B
Go
28 lines
893 B
Go
package oauth21
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"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) (*gen.AuthorizationRequest, error) {
|
|
if err := r.ParseForm(); err != nil {
|
|
return nil, fmt.Errorf("failed to parse form: %w", err)
|
|
}
|
|
|
|
v := &gen.AuthorizationRequest{
|
|
ClientId: r.Form.Get("client_id"),
|
|
RedirectUri: optionalFormParam(r, "redirect_uri"),
|
|
ResponseType: r.Form.Get("response_type"),
|
|
State: optionalFormParam(r, "state"),
|
|
CodeChallenge: optionalFormParam(r, "code_challenge"),
|
|
CodeChallengeMethod: optionalFormParam(r, "code_challenge_method"),
|
|
}
|
|
|
|
return v, nil
|
|
}
|