Skip to content
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

ignore alternative authorization header prefixes #4904

Open
wants to merge 13 commits into
base: dev
Choose a base branch
from

Conversation

Geal
Copy link
Contributor

@Geal Geal commented Apr 3, 2024

Follow up to #4718

This PR enables the JWT plugin to ignore other auth prefixes other than the one defined in the configuration.

This enables multiple Authorization schemes to be supported, although other schemes would need to be handled in either Rhai or a coprocessor to be used with the AuthN plugin.


Checklist

Complete the checklist (and note appropriate exceptions) before the PR is marked ready-for-review.

  • Changes are compatible1
  • Documentation2 completed
  • Performance impact assessed and acceptable
  • Tests added and passing3
    • Unit Tests
    • Integration Tests
    • Manual Tests

Exceptions

Note any exceptions here

Notes

Footnotes

  1. It may be appropriate to bring upcoming changes to the attention of other (impacted) groups. Please endeavour to do this before seeking PR approval. The mechanism for doing this will vary considerably, so use your judgement as to how and when to do this.

  2. Configuration is an important part of many changes. Where applicable please try to document configuration examples.

  3. Tick whichever testing boxes are applicable. If you are adding Manual Tests, please document the manual testing (extensively) in the Exceptions.

@Geal Geal requested a review from a team as a code owner April 3, 2024 15:52
@Geal Geal requested a review from garypen April 3, 2024 15:52
@Geal Geal requested a review from lleadbet April 3, 2024 15:52
@router-perf
Copy link

router-perf bot commented Apr 3, 2024

CI performance tests

  • reload - Reload test over a long period of time at a constant rate of users
  • events_big_cap_high_rate_callback - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity using callback mode
  • events_without_dedup_callback - Stress test for events with a lot of users and deduplication DISABLED using callback mode
  • large-request - Stress test with a 1 MB request payload
  • const - Basic stress test that runs with a constant number of users
  • no-graphos - Basic stress test, no GraphOS.
  • step-jemalloc-tuning - Clone of the basic stress test for jemalloc tuning
  • events - Stress test for events with a lot of users and deduplication ENABLED
  • events_callback - Stress test for events with a lot of users and deduplication ENABLED in callback mode
  • events_big_cap_high_rate - Stress test for events with a lot of users, deduplication enabled and high rate event with a big queue capacity
  • events_without_dedup - Stress test for events with a lot of users and deduplication DISABLED
  • xxlarge-request - Stress test with 100 MB request payload
  • xlarge-request - Stress test with 10 MB request payload
  • step - Basic stress test that steps up the number of users over time

@@ -139,7 +139,7 @@ The default value is `Authorization`.

The string that will always precede the JWT in the header value corresponding to [`header_name`](#header_name). This value must not include whitespace.

The default value is `Bearer`.
The default value is `Bearer`. If the router encounters authorization headers with a different prefix, it will ignore them.
Copy link
Contributor

Choose a reason for hiding this comment

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

The current default does the opposite, no? It will reject the request as far as I can tell.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, so it will be different from the current default. I don't want to add yet another option to keep a behaviour that did not make much sense. Do you think there are users that relied on checking the authorization header prefix instead of using the require_authentication option?

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I would guess they may use it as an expected behavior to fail if it isn't formatted correctly, including overall header structure. I can reach out to other SAs to get a gut check.

Copy link
Contributor

@garypen garypen left a comment

Choose a reason for hiding this comment

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

I think the change in behaviour is ok as long as the docs make the change clear.

@@ -0,0 +1,17 @@
### Ignore other auth prefixes in the JWT plugin

If the router encounters an authorization header with a different prefix in the value than what it expects, it will now ignore it. If the router was configured without the `require_authentication` option or without the authorization directives, then some requests that came with a different header prefix that were rejected before will now go through the router. If those options were configured, then there will be no change in behaviour.
Copy link
Contributor

Choose a reason for hiding this comment

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

Attempted clarification, but make sure it still makes sense.

Suggested change
If the router encounters an authorization header with a different prefix in the value than what it expects, it will now ignore it. If the router was configured without the `require_authentication` option or without the authorization directives, then some requests that came with a different header prefix that were rejected before will now go through the router. If those options were configured, then there will be no change in behaviour.
If the router encounters an authorization header with a different prefix to the configured value, it will now ignore it.
If the router is configured without the `require_authentication` option or without the authorization directives, then requests that have a different header prefix, that were previously rejected, will now go through the router.
If both of those options were configured, then there will be no change in behaviour.


If the router encounters an authorization header with a different prefix in the value than what it expects, it will now ignore it. If the router was configured without the `require_authentication` option or without the authorization directives, then some requests that came with a different header prefix that were rejected before will now go through the router. If those options were configured, then there will be no change in behaviour.

As an example, with a router configure like this:
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
As an example, with a router configure like this:
As an example, with a router configured like this:

header_value_prefix: "Bearer"
```

In the above, the router will ignore `Authorization: Basic <token>`, but process requests with `Authorization: Bearer <token>` defined.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
In the above, the router will ignore `Authorization: Basic <token>`, but process requests with `Authorization: Bearer <token>` defined.
In the above, the router will ignore requests with a `Authorization: Basic <token>` header and process requests with a `Authorization: Bearer <token>` header.

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.

None yet

3 participants