-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[auth] OAuth protected-resource-metadata: fallback on 4xx not just 404 #879
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
src/client/auth.test.ts
Outdated
@@ -212,11 +212,11 @@ describe("OAuth Authorization", () => { | |||
expect(url.toString()).toBe("https://resource.example.com/.well-known/oauth-protected-resource/path?param=value"); | |||
}); | |||
|
|||
it("falls back to root discovery when path-aware discovery returns 404", async () => { | |||
// First call (path-aware) returns 404 | |||
it("falls back to root discovery when path-aware discovery fails", async () => { |
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 we could make this a parameterised test (with it.each
) to check across many 4xx statuses?
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.
LGTM, thanks!
Co-authored-by: adam jones <domdomegg+git@gmail.com>
src/client/auth.test.ts
Outdated
@@ -212,11 +212,11 @@ describe("OAuth Authorization", () => { | |||
expect(url.toString()).toBe("https://resource.example.com/.well-known/oauth-protected-resource/path?param=value"); | |||
}); | |||
|
|||
it("falls back to root discovery when path-aware discovery returns 404", async () => { | |||
// First call (path-aware) returns 404 | |||
it("falls back to root discovery when path-aware discovery fails", async () => { |
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.
could also be good to add "falls back when path-aware discovery encounters internal server error" (to check the 500s are left out of the logic)
Motivation and Context
Some places will return a 401 or other 4xx status code when you probe for a metadata endpoint they don't support. Prior to this, we'd only fallback specifically on a 404, but if it's unauthorized, you're not guaranteed to get a 404.
Without this change, clients will fail trying to get the path-aware version and never try the supported root PRM path.
How Has This Been Tested?
Added tests
Breaking Changes
Unbreaks a change from introducing path-aware metadata
Types of changes
Checklist
Additional context