1
0
mirror of https://github.com/moparisthebest/curl synced 2025-03-07 20:59:41 -05:00

Set auth type differently, we use one CURLOPT_HTTPAUTH instead as we plan

to add more method in the future.
This commit is contained in:
Daniel Stenberg 2003-06-10 12:49:16 +00:00
parent d7980c1a45
commit d0cc92a01a
5 changed files with 52 additions and 34 deletions

View File

@ -7,10 +7,15 @@
Changelog Changelog
Daniel (10 June) Daniel (10 June)
- Modified how to set auth type to libcurl. Now use CURLOPT_HTTPAUTH instead,
and pick method. Supported ones currently are:
CURLHTTP_BASIC - default selection
CURLHTTP_DIGEST - formerly CURLOPT_HTTPDIGEST
CURLHTTP_NEGOTIATE
- Daniel Kouril added HTTP Negotiate authentication support, as defined in the - Daniel Kouril added HTTP Negotiate authentication support, as defined in the
IETF draft draft-brezak-spnego-http-04.txt. In use already by various IETF draft draft-brezak-spnego-http-04.txt. In use already by various
Microsoft web applications. CURLOPT_HTTPNEGOTIATE and --negotiate are the Microsoft web applications. --negotiate is the new family member.
new family members.
- A missing ending bracket (']') while doing URL globbing could lead to a - A missing ending bracket (']') while doing URL globbing could lead to a
segfault. While fixing this, I also introduced better error reporting in the segfault. While fixing this, I also introduced better error reporting in the

View File

@ -213,6 +213,14 @@ typedef enum {
CURLPROXY_SOCKS5 = 5 CURLPROXY_SOCKS5 = 5
} curl_proxytype; } curl_proxytype;
typedef enum {
CURLHTTP_BASIC = 0, /* default */
CURLHTTP_DIGEST = 1, /* Digest */
CURLHTTP_NEGOTIATE = 2, /* Negotiate */
CURLHTTP_NTLM = 3, /* NTLM */
CURLHTTP_LAST /* never to be used */
} curl_httpauth;
/* this was the error code 50 in 7.7.3 and a few earlier versions, this /* this was the error code 50 in 7.7.3 and a few earlier versions, this
is no longer used by libcurl but is instead #defined here only to not is no longer used by libcurl but is instead #defined here only to not
make programs break */ make programs break */
@ -625,13 +633,9 @@ typedef enum {
attempted before the good old traditional PORT command. */ attempted before the good old traditional PORT command. */
CINIT(FTP_USE_EPRT, LONG, 106), CINIT(FTP_USE_EPRT, LONG, 106),
/* Set this to a non-zero value to enable HTTP Digest Authentication. /* Set this to a curl_httpauth value to enable that particular authentication
You should use this in combination with CURLOPT_USERPWD. */ method. Use this in combination with CURLOPT_USERPWD. */
CINIT(HTTPDIGEST, LONG, 107), CINIT(HTTPAUTH, LONG, 107),
/* Set this to a non-zero value to enable HTTP Negotiate Authentication.
You should use this in combination with CURLOPT_USERPWD. */
CINIT(HTTPNEGOTIATE, LONG, 108),
CURLOPT_LASTENTRY /* the last unused */ CURLOPT_LASTENTRY /* the last unused */
} CURLoption; } CURLoption;

View File

@ -844,18 +844,38 @@ CURLcode Curl_setopt(struct SessionHandle *data, CURLoption option, ...)
data->set.encoding = (char*)ALL_CONTENT_ENCODINGS; data->set.encoding = (char*)ALL_CONTENT_ENCODINGS;
break; break;
case CURLOPT_HTTPDIGEST: case CURLOPT_HTTPAUTH:
/* /*
* Enable HTTP Digest Authentication * Set HTTP Authentication type.
*/ */
data->set.httpdigest = va_arg(param, long); {
break; curl_httpauth auth = va_arg(param, long);
switch(auth) {
case CURLHTTP_BASIC:
/* default */
data->set.httpdigest = FALSE;
data->set.httpnegotiate = FALSE;
break;
case CURLHTTP_DIGEST:
/* Enable HTTP Digest authentication */
data->set.httpdigest = TRUE;
data->set.httpnegotiate = FALSE;
break;
case CURLHTTP_NEGOTIATE:
#ifdef GSSAPI #ifdef GSSAPI
case CURLOPT_HTTPNEGOTIATE: /* Enable HTTP Negotaiate authentication */
/* Enable HTTP Negotaiate authentication */ data->set.httpdigest = FALSE;
data->set.httpnegotiate = va_arg(param, long); data->set.httpnegotiate = TRUE;
break; break;
#else
/* fall-through */
#endif #endif
default:
return CURLE_FAILED_INIT; /* unsupported type */
}
}
break;
case CURLOPT_USERPWD: case CURLOPT_USERPWD:
/* /*
* user:password to use in the operation * user:password to use in the operation

View File

@ -689,9 +689,7 @@ struct UserDefined {
long use_port; /* which port to use (when not using default) */ long use_port; /* which port to use (when not using default) */
char *userpwd; /* <user:password>, if used */ char *userpwd; /* <user:password>, if used */
bool httpdigest; /* if HTTP Digest is enabled */ bool httpdigest; /* if HTTP Digest is enabled */
#ifdef GSSAPI
bool httpnegotiate; /* if HTTP Negotiate authentication is enabled */ bool httpnegotiate; /* if HTTP Negotiate authentication is enabled */
#endif
char *set_range; /* range, if used. See README for detailed specification char *set_range; /* range, if used. See README for detailed specification
on this syntax. */ on this syntax. */
long followlocation; /* as in HTTP Location: */ long followlocation; /* as in HTTP Location: */

View File

@ -359,9 +359,7 @@ static void help(void)
" -d/--data <data> HTTP POST data (H)\n" " -d/--data <data> HTTP POST data (H)\n"
" --data-ascii <data> HTTP POST ASCII data (H)\n" " --data-ascii <data> HTTP POST ASCII data (H)\n"
" --data-binary <data> HTTP POST binary data (H)\n" " --data-binary <data> HTTP POST binary data (H)\n"
#ifdef GSSAPI " --negotiate Enable HTTP Negotiate Authentication (req GSS-lib)\n"
" --negotiate Enable HTTP Negotiate Authentication\n"
#endif
" --digest Enable HTTP Digest Authentication"); " --digest Enable HTTP Digest Authentication");
puts(" --disable-eprt Prevents curl from using EPRT or LPRT (F)\n" puts(" --disable-eprt Prevents curl from using EPRT or LPRT (F)\n"
" --disable-epsv Prevents curl from using EPSV (F)\n" " --disable-epsv Prevents curl from using EPSV (F)\n"
@ -464,9 +462,7 @@ struct Configurable {
bool cookiesession; /* new session? */ bool cookiesession; /* new session? */
bool encoding; /* Accept-Encoding please */ bool encoding; /* Accept-Encoding please */
bool digest; /* Digest Authentication */ bool digest; /* Digest Authentication */
#ifdef GSSAPI
bool negotiate; /* Negotiate Authentication */ bool negotiate; /* Negotiate Authentication */
#endif
bool use_resume; bool use_resume;
bool resume_from_current; bool resume_from_current;
bool disable_epsv; bool disable_epsv;
@ -1059,9 +1055,7 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
{"5i", "limit-rate", TRUE}, {"5i", "limit-rate", TRUE},
{"5j", "compressed", FALSE}, /* might take an arg someday */ {"5j", "compressed", FALSE}, /* might take an arg someday */
{"5k", "digest", FALSE}, {"5k", "digest", FALSE},
#ifdef GSSAPI
{"5l", "negotiate", FALSE}, {"5l", "negotiate", FALSE},
#endif
{"0", "http1.0", FALSE}, {"0", "http1.0", FALSE},
{"1", "tlsv1", FALSE}, {"1", "tlsv1", FALSE},
{"2", "sslv2", FALSE}, {"2", "sslv2", FALSE},
@ -1290,11 +1284,9 @@ static ParameterError getparameter(char *flag, /* f or -long-flag */
config->digest ^= TRUE; config->digest ^= TRUE;
break; break;
#ifdef GSSAPI
case 'l': /* --negotiate */ case 'l': /* --negotiate */
config->negotiate ^= TRUE; config->negotiate ^= TRUE;
break; break;
#endif
default: /* the URL! */ default: /* the URL! */
{ {
@ -2989,12 +2981,11 @@ operate(struct Configurable *config, int argc, char *argv[])
/* disable it */ /* disable it */
curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, FALSE); curl_easy_setopt(curl, CURLOPT_FTP_USE_EPRT, FALSE);
/* new in libcurl 7.10.6 */ /* new in libcurl 7.10.6 (default is Basic) */
curl_easy_setopt(curl, CURLOPT_HTTPDIGEST, config->digest); if(config->digest)
curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLHTTP_DIGEST);
#ifdef GSSAPI else if(config->negotiate)
curl_easy_setopt(curl, CURLOPT_HTTPNEGOTIATE, config->negotiate); curl_easy_setopt(curl, CURLOPT_HTTPAUTH, CURLHTTP_NEGOTIATE);
#endif
/* new in curl 7.9.7 */ /* new in curl 7.9.7 */
if(config->trace_dump) { if(config->trace_dump) {