-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[v2] Fix bug with auth_scheme_preference #10169
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
base: v2
Are you sure you want to change the base?
Changes from all commits
527f455
5be9c66
e09d885
77e7f7c
24c9076
b5e9d0b
7a4c270
9a8cd56
0563fe8
8daf219
5e9e1a2
9847e4e
cc0548f
edc7fd5
a40c847
5681b21
cd01f69
fb7201f
8f3212e
7f9f88b
ee60b5b
bb313cd
7697542
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| { | ||
| "type": "bugfix", | ||
| "category": "signing", | ||
| "description": "Fix bug so that configured auth scheme preference is used when auth scheme is resolved from endpoints rulesets, or from operation-level auth trait. Auth scheme preference can be configured using the existing ``auth_scheme_preference`` shared config setting, or the existing ``AWS_AUTH_SCHEME_PREFERENCE`` environment variable." | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,7 @@ | |
|
|
||
| import jmespath | ||
| from botocore import UNSIGNED, xform_name | ||
| from botocore.auth import AUTH_TYPE_MAPS | ||
| from botocore.auth import AUTH_TYPE_MAPS, resolve_auth_scheme_preference | ||
| from botocore.endpoint_provider import EndpointProvider | ||
| from botocore.exceptions import ( | ||
| EndpointProviderError, | ||
|
|
@@ -471,6 +471,7 @@ def __init__( | |
| event_emitter, | ||
| use_ssl=True, | ||
| requested_auth_scheme=None, | ||
| auth_scheme_preference=None, | ||
| ): | ||
| self._provider = EndpointProvider( | ||
| ruleset_data=endpoint_ruleset_data, | ||
|
|
@@ -483,6 +484,7 @@ def __init__( | |
| self._event_emitter = event_emitter | ||
| self._use_ssl = use_ssl | ||
| self._requested_auth_scheme = requested_auth_scheme | ||
| self._auth_scheme_preference = auth_scheme_preference | ||
| self._instance_cache = {} | ||
|
|
||
| def construct_endpoint( | ||
|
|
@@ -698,6 +700,9 @@ def auth_schemes_to_signing_ctx(self, auth_schemes): | |
| if self._requested_auth_scheme == UNSIGNED: | ||
| return 'none', {} | ||
|
|
||
| available_ruleset_names = [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nit, non-blocking] Since this is only used in the elif block, I think it would make more sense to define in that scope.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tried that, but then im forced to make other code dirtier. Available ruleset names needs auth schemes before the sig prefix is stripped. Putting into the elif block would require us to put the sig prefix stripping code into the if and the else blocks. |
||
| s['name'].split('#')[-1] for s in auth_schemes | ||
| ] | ||
| auth_schemes = [ | ||
| {**scheme, 'name': self._strip_sig_prefix(scheme['name'])} | ||
| for scheme in auth_schemes | ||
|
|
@@ -719,6 +724,14 @@ def auth_schemes_to_signing_ctx(self, auth_schemes): | |
| # exception, instead default to the logic in botocore | ||
| # customizations. | ||
| return None, {} | ||
| elif self._auth_scheme_preference is not None: | ||
| prefs = self._auth_scheme_preference.split(',') | ||
| auth_schemes_by_auth_type = { | ||
| self._strip_sig_prefix(s['name'].split('#')[-1]): s | ||
| for s in auth_schemes | ||
| } | ||
| name = resolve_auth_scheme_preference(prefs, available_ruleset_names) | ||
| scheme = auth_schemes_by_auth_type[name] | ||
| else: | ||
| try: | ||
| name, scheme = next( | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.