Skip to content

Add Check PCKE Support - #563

Merged
samthanawalla merged 9 commits into
modelcontextprotocol:mainfrom
RyoKusnadi:ryo/check-pcke-support
Oct 14, 2025
Merged

samthanawalla merged 9 commits into
modelcontextprotocol:mainfrom
RyoKusnadi:ryo/check-pcke-support

Conversation

@RyoKusnadi

@RyoKusnadi RyoKusnadi commented Oct 7, 2025 •

Copy link
Copy Markdown
Contributor

Refer To Issue 473
Changes:

  • Add check for PKCE support via server metadata and return an error if not supported.

@samthanawalla
samthanawalla self-requested a review October 7, 2025 16:37

@samthanawalla samthanawalla left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR!
I moved some stuff around so you will have to rebase!

Comment thread oauthex/oauthex.go Outdated
// RequirePKCE checks that the authorization server for issuerURL supports PKCE,
// by verifying that CodeChallengeMethodsSupported is non-empty.
// It returns an error if metadata cannot be fetched or PKCE is not advertised.
func RequirePKCE(ctx context.Context, issuerURL string, c *http.Client) error {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move this to auth_meta after rebasing

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revised

Comment thread oauthex/oauthex.go Resolved
@RyoKusnadi
RyoKusnadi force-pushed the ryo/check-pcke-support branch from 6d6e1c2 to 40f7fb4 Compare October 8, 2025 13:40
@RyoKusnadi

RyoKusnadi commented Oct 8, 2025 •

Copy link
Copy Markdown
Contributor Author

Hi @samthanawalla updated, kindly help to review again. thanks!

Comment thread oauthex/auth_meta.go Outdated
return nil, fmt.Errorf("failed to get auth server metadata from %q: %w", issuerURL, errors.Join(errs...))
}

// RequirePKCE checks that the authorization server for issuerURL supports PKCE,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we should have an exported function for this. Why can't we do it inside GetAuthServerMeta?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revised

Comment thread oauthex/auth_meta_test.go Outdated
}
}

func TestGetAuthServerMetaRequirePKCE(t *testing.T) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't actually test that we do the check. There needs to be a test for an auth server that doesn't do PKCE.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revised

Comment thread oauthex/auth_meta_test.go Outdated
tests := []struct {
name string
hasPKCESupport bool
expectError bool

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

s/expect/want/

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also wantError can be a string, if empty, then no error is expected, otherwise the error should contain that string.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

revised

@RyoKusnadi
RyoKusnadi requested a review from jba October 14, 2025 13:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants