-
-
Notifications
You must be signed in to change notification settings - Fork 5
Add a 401 HTML page #1073
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
Merged
Add a 401 HTML page #1073
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,185 @@ | ||
| # An unauthorized caller gets an identical 401 for a protected path whether or | ||
| # not the schema exists, because the gate denies before the existence check. | ||
| # The JSON surface answers with an RFC 9457 problem document and the HTML | ||
| # surface with the index-time 401 page. Existence is only revealed to a caller | ||
| # the policy admits. | ||
|
|
||
| # JSON, existing protected schema, no credential: the full problem document, | ||
| # round-tripped through its own output schema | ||
| GET {{base}}/private/secret.json | ||
| HTTP 401 | ||
| Cache-Control: no-store | ||
| Content-Type: application/problem+json | ||
| WWW-Authenticate: Bearer realm="registry" | ||
| Access-Control-Allow-Origin: * | ||
| Access-Control-Expose-Headers: Link, ETag | ||
| Link: </self/v1/schemas/api/error>; rel="describedby" | ||
| [Captures] | ||
| denied_body: body | ||
| denied_schema: header "Link" regex "<([^>]+)>" | ||
| [Asserts] | ||
| header "ETag" not exists | ||
| header "Last-Modified" not exists | ||
| jsonpath "$.type" == "urn:sourcemeta:one:authentication-required" | ||
| jsonpath "$.title" == "Unauthorized" | ||
| jsonpath "$.status" == 401 | ||
| jsonpath "$.detail" == "This resource requires authentication" | ||
|
|
||
| POST {{base}}/self/v1/api/schemas/evaluate{{denied_schema}} | ||
| ``` | ||
| {{denied_body}} | ||
| ``` | ||
| HTTP 200 | ||
| [Asserts] | ||
| jsonpath "$.valid" == true | ||
|
|
||
| # JSON, nonexistent path under the same protected prefix, no credential: the | ||
| # byte-identical problem document, so probing cannot distinguish a real schema | ||
| # from a guess | ||
| GET {{base}}/private/ghost.json | ||
| HTTP 401 | ||
| Cache-Control: no-store | ||
| Content-Type: application/problem+json | ||
| WWW-Authenticate: Bearer realm="registry" | ||
| Access-Control-Allow-Origin: * | ||
| Access-Control-Expose-Headers: Link, ETag | ||
| Link: </self/v1/schemas/api/error>; rel="describedby" | ||
| [Captures] | ||
| ghost_body: body | ||
| ghost_schema: header "Link" regex "<([^>]+)>" | ||
| [Asserts] | ||
| jsonpath "$.type" == "urn:sourcemeta:one:authentication-required" | ||
| jsonpath "$.title" == "Unauthorized" | ||
| jsonpath "$.status" == 401 | ||
| jsonpath "$.detail" == "This resource requires authentication" | ||
|
|
||
| POST {{base}}/self/v1/api/schemas/evaluate{{ghost_schema}} | ||
| ``` | ||
| {{ghost_body}} | ||
| ``` | ||
| HTTP 200 | ||
| [Asserts] | ||
| jsonpath "$.valid" == true | ||
|
|
||
| # JSON, with the admitting credential, existing schema: the schema itself | ||
| GET {{base}}/private/secret.json | ||
| Authorization: Bearer primary-secret-key | ||
| HTTP 200 | ||
| Cache-Control: public, max-age=0, must-revalidate | ||
| Content-Type: application/schema+json | ||
| Access-Control-Allow-Origin: * | ||
| Access-Control-Expose-Headers: Link, ETag | ||
| Link: <https://json-schema.org/draft/2020-12/schema>; rel="describedby" | ||
| [Asserts] | ||
| header "ETag" exists | ||
| { | ||
| "$schema": "https://json-schema.org/draft/2020-12/schema", | ||
| "$id": "{{base}}/private/secret", | ||
| "type": "object", | ||
| "required": [ "token" ], | ||
| "properties": { | ||
| "token": { | ||
| "type": "string" | ||
| } | ||
| }, | ||
| "additionalProperties": false | ||
| } | ||
|
|
||
| # JSON, with the credential, nonexistent: existence is now revealed as a genuine | ||
| # 404 problem document, round-tripped through its output schema | ||
| GET {{base}}/private/ghost.json | ||
| Authorization: Bearer primary-secret-key | ||
| HTTP 404 | ||
| Cache-Control: no-store | ||
| Content-Type: application/problem+json | ||
| Access-Control-Allow-Origin: * | ||
| Access-Control-Expose-Headers: Link, ETag | ||
| Link: </self/v1/schemas/api/error>; rel="describedby" | ||
| [Captures] | ||
| missing_body: body | ||
| missing_schema: header "Link" regex "<([^>]+)>" | ||
| [Asserts] | ||
| jsonpath "$.type" == "urn:sourcemeta:one:not-found" | ||
| jsonpath "$.title" == "Not Found" | ||
| jsonpath "$.status" == 404 | ||
| jsonpath "$.detail" == "There is nothing at this URL" | ||
|
|
||
| POST {{base}}/self/v1/api/schemas/evaluate{{missing_schema}} | ||
| ``` | ||
| {{missing_body}} | ||
| ``` | ||
| HTTP 200 | ||
| [Asserts] | ||
| jsonpath "$.valid" == true | ||
|
|
||
| # HTML, existing protected schema, no credential: the 401 page, carrying the | ||
| # same bearer challenge and no-store discipline as the JSON envelope | ||
| GET {{base}}/private/secret | ||
| Accept: text/html | ||
| HTTP 401 | ||
| Cache-Control: no-store | ||
| Content-Type: text/html; charset=utf-8 | ||
| WWW-Authenticate: Bearer realm="registry" | ||
| Referrer-Policy: strict-origin-when-cross-origin | ||
| Content-Security-Policy: frame-ancestors 'none' | ||
| X-Frame-Options: DENY | ||
| Vary: Accept, Accept-Encoding | ||
| [Asserts] | ||
| xpath "string(//title)" == "Unauthorized" | ||
| xpath "string(//h2[@class='fw-bold'])" == "This page requires authentication" | ||
| xpath "string(//p[@class='lead'])" == "Present a valid credential to access it" | ||
|
|
||
| # HTML, nonexistent path under the protected prefix, no credential: the | ||
| # byte-identical 401 page, so the HTML surface leaks no existence either | ||
| GET {{base}}/private/ghost | ||
| Accept: text/html | ||
| HTTP 401 | ||
| Cache-Control: no-store | ||
| Content-Type: text/html; charset=utf-8 | ||
| WWW-Authenticate: Bearer realm="registry" | ||
| Referrer-Policy: strict-origin-when-cross-origin | ||
| Content-Security-Policy: frame-ancestors 'none' | ||
| X-Frame-Options: DENY | ||
| Vary: Accept, Accept-Encoding | ||
| [Asserts] | ||
| xpath "string(//title)" == "Unauthorized" | ||
| xpath "string(//h2[@class='fw-bold'])" == "This page requires authentication" | ||
| xpath "string(//p[@class='lead'])" == "Present a valid credential to access it" | ||
|
|
||
| # HTML, a credential the policy does not admit: the byte-identical 401 page, so | ||
| # the response never reveals that a credential was presented at all | ||
| GET {{base}}/private/secret | ||
| Accept: text/html | ||
| Authorization: Bearer not-the-key | ||
| HTTP 401 | ||
| Cache-Control: no-store | ||
| Content-Type: text/html; charset=utf-8 | ||
| WWW-Authenticate: Bearer realm="registry" | ||
| Referrer-Policy: strict-origin-when-cross-origin | ||
| Content-Security-Policy: frame-ancestors 'none' | ||
| X-Frame-Options: DENY | ||
| Vary: Accept, Accept-Encoding | ||
| [Asserts] | ||
| xpath "string(//title)" == "Unauthorized" | ||
| xpath "string(//h2[@class='fw-bold'])" == "This page requires authentication" | ||
| xpath "string(//p[@class='lead'])" == "Present a valid credential to access it" | ||
|
|
||
| # HTML, with the admitting credential: the real schema page, never the 401 page | ||
| GET {{base}}/private/secret | ||
| Accept: text/html | ||
| Authorization: Bearer primary-secret-key | ||
| HTTP 200 | ||
| Cache-Control: public, max-age=0, must-revalidate | ||
| [Asserts] | ||
| header "Content-Type" contains "text/html" | ||
| xpath "string(//title)" != "Unauthorized" | ||
|
|
||
| # HTML, the public carve-out under the protected prefix: anonymous, never the | ||
| # 401 page | ||
| GET {{base}}/private/open/shared | ||
| Accept: text/html | ||
| HTTP 200 | ||
| Cache-Control: public, max-age=0, must-revalidate | ||
| [Asserts] | ||
| header "Content-Type" contains "text/html" | ||
| xpath "string(//title)" != "Unauthorized" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.