-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix oauth well-known paths to retain path and query #756
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thank you! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ihrpr !
src/client/auth.ts
Outdated
@@ -261,7 +261,10 @@ export async function discoverOAuthProtectedResourceMetadata( | |||
if (opts?.resourceMetadataUrl) { | |||
url = new URL(opts?.resourceMetadataUrl); | |||
} else { | |||
url = new URL("/.well-known/oauth-protected-resource", serverUrl); | |||
const issuer = new URL(serverUrl); | |||
const wellKnownPath = buildWellKnownPath('oauth-protected-resource', issuer.pathname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should have a fallback to the non-path-suffixed well-known path, as we do for the AS (see discoverOAuthMetadata), otherwise this will be a breaking change.
RFC9728 does mention the path suffix, but also states "By default, the well-known URI string used is /.well-known/oauth-protected-resource".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm Okay with the breaking changes if it means it's spec compliant. But yeah ""By default, the well-known URI string used is /.well-known/oauth-protected-resource". - this is still compliant, let me add fallback
src/client/auth.ts
Outdated
@@ -361,8 +364,9 @@ export async function discoverOAuthMetadata( | |||
const protocolVersion = opts?.protocolVersion ?? LATEST_PROTOCOL_VERSION; | |||
|
|||
// Try path-aware discovery first (RFC 8414 compliant) | |||
const wellKnownPath = buildWellKnownPath(issuer.pathname); | |||
const wellKnownPath = buildWellKnownPath('oauth-authorization-server', issuer.pathname); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe this whole block w/ try suffix else fallback could be factored out / reused for both cases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great, thanks @ihrpr !
Hey @ihrpr For the case where
This line here is making the fallback attempt on the issuer URL when it should be done on the typescript-sdk/src/client/auth.ts Line 573 in 16ea277
Might be related to this issue: #744 |
Background #733