mirror of
https://github.com/curl/curl.git
synced 2026-07-26 00:27:16 +03:00
sasl: make login option string override http auth
- Use http authentication mechanisms as a default, not a preset. Consider http authentication options which are mapped to SASL options as a default (overriding the hardcoded default mask for the protocol) that is ignored if a login option string is given. Prior to this change, if some HTTP auth options were given, sasl mapped http authentication options to sasl ones but merged them with the login options. That caused problems with the cli tool that sets the http login option CURLAUTH_BEARER as a side-effect of --oauth2-bearer, because this flag maps to more than one sasl mechanisms and the latter cannot be cleared individually by the login options string. New test 992 checks this. Fixes https://github.com/curl/curl/issues/10259 Closes https://github.com/curl/curl/pull/12790
This commit is contained in:
parent
65c7e4f92b
commit
7b2d98dfad
3 changed files with 65 additions and 8 deletions
|
|
@ -205,18 +205,23 @@ void Curl_sasl_init(struct SASL *sasl, struct Curl_easy *data,
|
|||
sasl->force_ir = FALSE; /* Respect external option */
|
||||
|
||||
if(auth != CURLAUTH_BASIC) {
|
||||
sasl->resetprefs = FALSE;
|
||||
sasl->prefmech = SASL_AUTH_NONE;
|
||||
unsigned short mechs = SASL_AUTH_NONE;
|
||||
|
||||
/* If some usable http authentication options have been set, determine
|
||||
new defaults from them. */
|
||||
if(auth & CURLAUTH_BASIC)
|
||||
sasl->prefmech |= SASL_MECH_PLAIN | SASL_MECH_LOGIN;
|
||||
mechs |= SASL_MECH_PLAIN | SASL_MECH_LOGIN;
|
||||
if(auth & CURLAUTH_DIGEST)
|
||||
sasl->prefmech |= SASL_MECH_DIGEST_MD5;
|
||||
mechs |= SASL_MECH_DIGEST_MD5;
|
||||
if(auth & CURLAUTH_NTLM)
|
||||
sasl->prefmech |= SASL_MECH_NTLM;
|
||||
mechs |= SASL_MECH_NTLM;
|
||||
if(auth & CURLAUTH_BEARER)
|
||||
sasl->prefmech |= SASL_MECH_OAUTHBEARER | SASL_MECH_XOAUTH2;
|
||||
mechs |= SASL_MECH_OAUTHBEARER | SASL_MECH_XOAUTH2;
|
||||
if(auth & CURLAUTH_GSSAPI)
|
||||
sasl->prefmech |= SASL_MECH_GSSAPI;
|
||||
mechs |= SASL_MECH_GSSAPI;
|
||||
|
||||
if(mechs != SASL_AUTH_NONE)
|
||||
sasl->prefmech = mechs;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue