| 903 | |
| 904 | |
| 905 | def resolve_auth_scheme_preference(preference_list, auth_options): |
| 906 | service_supported = [scheme.split('#')[-1] for scheme in auth_options] |
| 907 | |
| 908 | unsupported = [ |
| 909 | scheme |
| 910 | for scheme in preference_list |
| 911 | if scheme not in AUTH_PREF_TO_SIGNATURE_VERSION |
| 912 | ] |
| 913 | if unsupported: |
| 914 | logger.debug( |
| 915 | f"Unsupported auth schemes in preference list: {', '.join(unsupported)}" |
| 916 | ) |
| 917 | |
| 918 | combined = preference_list + service_supported |
| 919 | prioritized_schemes = [ |
| 920 | scheme |
| 921 | for scheme in dict.fromkeys(combined) |
| 922 | if scheme in service_supported |
| 923 | ] |
| 924 | |
| 925 | for scheme in prioritized_schemes: |
| 926 | if scheme == 'noAuth': |
| 927 | return AUTH_PREF_TO_SIGNATURE_VERSION[scheme] |
| 928 | sig_version = AUTH_PREF_TO_SIGNATURE_VERSION.get(scheme) |
| 929 | if sig_version in AUTH_TYPE_MAPS: |
| 930 | return sig_version |
| 931 | |
| 932 | raise UnsupportedSignatureVersionError( |
| 933 | signature_version=', '.join(sorted(service_supported)) |
| 934 | ) |
| 935 | |
| 936 | |
| 937 | # Defined at the bottom instead of the top of the module because the Auth |