Parcourir la source

tool: add AWS HTTP v4 Signature support

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
Matthias Gatto il y a 3 ans
Parent
commit
6b27df8269
5 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. 2 0
      src/tool_cfgable.c
  2. 1 0
      src/tool_cfgable.h
  3. 5 0
      src/tool_getparam.c
  4. 2 0
      src/tool_help.c
  5. 2 0
      src/tool_operate.c

+ 2 - 0
src/tool_cfgable.c

@@ -168,6 +168,8 @@ static void free_config_fields(struct OperationConfig *config)
 
   Curl_safefree(config->ftp_account);
   Curl_safefree(config->ftp_alternative_to_user);
+
+  Curl_safefree(config->aws_sigv4_provider);
 }
 
 void config_free(struct OperationConfig *config)

+ 1 - 0
src/tool_cfgable.h

@@ -284,6 +284,7 @@ struct OperationConfig {
                                      0 is valid. default: CURL_HET_DEFAULT. */
   bool haproxy_protocol;          /* whether to send HAProxy protocol v1 */
   bool disallow_username_in_url;  /* disallow usernames in URLs */
+  char *aws_sigv4_provider;
   struct GlobalConfig *global;
   struct OperationConfig *prev;
   struct OperationConfig *next;   /* Always last in the struct */

+ 5 - 0
src/tool_getparam.c

@@ -113,6 +113,7 @@ static const struct LongShort aliases[]= {
   {"*t", "proxy-ntlm",               ARG_BOOL},
   {"*u", "crlf",                     ARG_BOOL},
   {"*v", "stderr",                   ARG_FILENAME},
+  {"*V", "aws-sigv4",             ARG_STRING},
   {"*w", "interface",                ARG_STRING},
   {"*x", "krb",                      ARG_STRING},
   {"*x", "krb4",                     ARG_STRING},
@@ -803,6 +804,10 @@ ParameterError getparameter(const char *flag, /* f or -long-flag */
         config->crlf = toggle;
         break;
 
+      case 'V': /* --aws-sigv4 */
+        config->authtype |= CURLAUTH_AWS_SIGV4;
+        GetStr(&config->aws_sigv4_provider, nextarg);
+        break;
       case 'v': /* --stderr */
         if(strcmp(nextarg, "-")) {
           FILE *newfile = fopen(nextarg, FOPEN_WRITETEXT);

+ 2 - 0
src/tool_help.c

@@ -817,6 +817,8 @@ static const struct helptxt helptext[] = {
   {"-A, --user-agent <name>",
    "Send User-Agent <name> to server",
    CURLHELP_IMPORTANT | CURLHELP_HTTP},
+  {"    --aws-sigv4 <provider1[:provider2]>",
+   "Use HTTP AWS V4 Signature", CURLHELP_HTTP},
   {"-v, --verbose",
    "Make the operation more talkative",
    CURLHELP_IMPORTANT | CURLHELP_VERBOSE},

+ 2 - 0
src/tool_operate.c

@@ -1661,6 +1661,8 @@ static CURLcode single_transfer(struct GlobalConfig *global,
           my_setopt_str(curl, CURLOPT_SSLKEYTYPE, config->key_type);
           my_setopt_str(curl, CURLOPT_PROXY_SSLKEYTYPE,
                         config->proxy_key_type);
+          my_setopt_str(curl, CURLOPT_AWS_SIGV4,
+                        config->aws_sigv4_provider);
 
           if(config->insecure_ok) {
             my_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);