diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-14 20:36:37 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-14 20:36:37 +0200 |
commit | bb80d3feebdc9acc52e3f4ad24084d8425f043a2 (patch) | |
tree | 2084a84c39f159c6aea254775dc0880d52579d45 /plugins/common/OAuth1Support.vala | |
parent | b26ff0798252a1a8072dd2c7a67f6205de9fde11 (diff) | |
parent | 31804433d72460cbe0a39f9f8ea5e76058d84cda (diff) |
Merge branch 'feature/upstream' into develop
Diffstat (limited to 'plugins/common/OAuth1Support.vala')
-rw-r--r-- | plugins/common/OAuth1Support.vala | 25 |
1 files changed, 10 insertions, 15 deletions
diff --git a/plugins/common/OAuth1Support.vala b/plugins/common/OAuth1Support.vala index e5a8545..05ba34f 100644 --- a/plugins/common/OAuth1Support.vala +++ b/plugins/common/OAuth1Support.vala @@ -6,7 +6,6 @@ */ namespace Publishing.RESTSupport.OAuth1 { - internal const string ENCODE_RFC_3986_EXTRA = "!*'();:@&=+$,/?%#[] \\"; public class Session : Publishing.RESTSupport.Session { private string? request_phase_token = null; @@ -62,7 +61,7 @@ namespace Publishing.RESTSupport.OAuth1 { Publishing.RESTSupport.Argument[] sorted_args = Publishing.RESTSupport.Argument.sort(base_string_arguments); - var arguments_string = Argument.serialize_list(sorted_args); + var arguments_string = Argument.serialize_for_sbs(sorted_args); string? signing_key = null; if (access_phase_token_secret != null) { @@ -80,9 +79,9 @@ namespace Publishing.RESTSupport.OAuth1 { signing_key = consumer_secret + "&"; } - string signature_base_string = http_method + "&" + Soup.URI.encode( - txn.get_endpoint_url(), ENCODE_RFC_3986_EXTRA) + "&" + - Soup.URI.encode(arguments_string, ENCODE_RFC_3986_EXTRA); + string signature_base_string = http_method + "&" + GLib.Uri.escape_string( + txn.get_endpoint_url()) + "&" + + GLib.Uri.escape_string (arguments_string); debug("signature base string = '%s'", signature_base_string); @@ -90,7 +89,7 @@ namespace Publishing.RESTSupport.OAuth1 { // compute the signature string signature = RESTSupport.hmac_sha1(signing_key, signature_base_string); - signature = Soup.URI.encode(signature, ENCODE_RFC_3986_EXTRA); + signature = GLib.Uri.escape_string(signature); debug("signature = '%s'", signature); @@ -111,11 +110,8 @@ namespace Publishing.RESTSupport.OAuth1 { } public string get_oauth_nonce() { - TimeVal currtime = TimeVal(); - currtime.get_current_time(); - - return Checksum.compute_for_string(ChecksumType.MD5, currtime.tv_sec.to_string() + - currtime.tv_usec.to_string()); + return Checksum.compute_for_string(ChecksumType.MD5, + GLib.get_real_time().to_string()); } public string get_oauth_timestamp() { @@ -178,12 +174,11 @@ namespace Publishing.RESTSupport.OAuth1 { } } - - public override void execute() throws Spit.Publishing.PublishingError { + public override async void execute_async() throws Spit.Publishing.PublishingError { var signature = ((Session) get_parent_session()).sign_transaction(this); add_argument("oauth_signature", signature); - base.execute(); + yield base.execute_async(); } } @@ -212,7 +207,7 @@ namespace Publishing.RESTSupport.OAuth1 { } public string get_authorization_header_string() { - return "OAuth " + Argument.serialize_list(auth_header_fields, true, ", "); + return "OAuth " + Argument.serialize_list(auth_header_fields, false, true, ", "); } public void authorize() { |