mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 16:18:48 -05:00
curl: added basic SASL XOAUTH2 support
Added the ability to specify an XOAUTH2 bearer token [RFC6750] via the --bearer option. Example usage: curl --url "imaps://imap.gmail.com:993/INBOX/;UID=1" --ssl-reqd --bearer ya29.AHES6Z...OMfsHYI --user username@example.com
This commit is contained in:
parent
84789e12fb
commit
e7dcc454c6
@ -96,6 +96,8 @@ void free_config_fields(struct Configurable *config)
|
|||||||
Curl_safefree(config->krblevel);
|
Curl_safefree(config->krblevel);
|
||||||
Curl_safefree(config->trace_dump);
|
Curl_safefree(config->trace_dump);
|
||||||
|
|
||||||
|
Curl_safefree(config->xoauth2_bearer);
|
||||||
|
|
||||||
config->trace_stream = NULL; /* closed elsewhere when appropriate */
|
config->trace_stream = NULL; /* closed elsewhere when appropriate */
|
||||||
|
|
||||||
Curl_safefree(config->writeout);
|
Curl_safefree(config->writeout);
|
||||||
|
@ -208,6 +208,7 @@ struct Configurable {
|
|||||||
#ifdef CURLDEBUG
|
#ifdef CURLDEBUG
|
||||||
bool test_event_based;
|
bool test_event_based;
|
||||||
#endif
|
#endif
|
||||||
|
char *xoauth2_bearer; /* XOAUTH2 bearer token */
|
||||||
}; /* struct Configurable */
|
}; /* struct Configurable */
|
||||||
|
|
||||||
void free_config_fields(struct Configurable *config);
|
void free_config_fields(struct Configurable *config);
|
||||||
|
@ -75,6 +75,7 @@ static const struct LongShort aliases[]= {
|
|||||||
{"*", "url", TRUE},
|
{"*", "url", TRUE},
|
||||||
{"*a", "random-file", TRUE},
|
{"*a", "random-file", TRUE},
|
||||||
{"*b", "egd-file", TRUE},
|
{"*b", "egd-file", TRUE},
|
||||||
|
{"*B", "bearer", TRUE},
|
||||||
{"*c", "connect-timeout", TRUE},
|
{"*c", "connect-timeout", TRUE},
|
||||||
{"*d", "ciphers", TRUE},
|
{"*d", "ciphers", TRUE},
|
||||||
{"*e", "disable-epsv", FALSE},
|
{"*e", "disable-epsv", FALSE},
|
||||||
@ -498,6 +499,9 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
case 'b': /* egd-file */
|
case 'b': /* egd-file */
|
||||||
GetStr(&config->egd_file, nextarg);
|
GetStr(&config->egd_file, nextarg);
|
||||||
break;
|
break;
|
||||||
|
case 'B': /* XOAUTH2 Bearer */
|
||||||
|
GetStr(&config->xoauth2_bearer, nextarg);
|
||||||
|
break;
|
||||||
case 'c': /* connect-timeout */
|
case 'c': /* connect-timeout */
|
||||||
err = str2udouble(&config->connecttimeout, nextarg);
|
err = str2udouble(&config->connecttimeout, nextarg);
|
||||||
if(err)
|
if(err)
|
||||||
@ -1632,9 +1636,11 @@ ParameterError getparameter(char *flag, /* f or -long-flag */
|
|||||||
/* user:password */
|
/* user:password */
|
||||||
GetStr(&config->userpwd, nextarg);
|
GetStr(&config->userpwd, nextarg);
|
||||||
cleanarg(nextarg);
|
cleanarg(nextarg);
|
||||||
err = checkpasswd("host", &config->userpwd);
|
if(!config->xoauth2_bearer) {
|
||||||
if(err)
|
err = checkpasswd("host", &config->userpwd);
|
||||||
return err;
|
if(err)
|
||||||
|
return err;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case 'U':
|
case 'U':
|
||||||
/* Proxy user:password */
|
/* Proxy user:password */
|
||||||
|
@ -977,6 +977,9 @@ int operate(struct Configurable *config, int argc, argv_item_t argv[])
|
|||||||
else if(!config->use_metalink)
|
else if(!config->use_metalink)
|
||||||
my_setopt(curl, CURLOPT_HEADER, config->include_headers?1L:0L);
|
my_setopt(curl, CURLOPT_HEADER, config->include_headers?1L:0L);
|
||||||
|
|
||||||
|
if(config->xoauth2_bearer)
|
||||||
|
my_setopt_str(curl, CURLOPT_XOAUTH2_BEARER, config->xoauth2_bearer);
|
||||||
|
|
||||||
#if !defined(CURL_DISABLE_PROXY)
|
#if !defined(CURL_DISABLE_PROXY)
|
||||||
{
|
{
|
||||||
/* TODO: Make this a run-time check instead of compile-time one. */
|
/* TODO: Make this a run-time check instead of compile-time one. */
|
||||||
|
Loading…
Reference in New Issue
Block a user