diff options
author | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:35:52 +0200 |
---|---|---|
committer | Jörg Frings-Fürst <debian@jff.email> | 2023-06-28 21:35:52 +0200 |
commit | b86540b743f1a87a163ffb811c8fe22a01fefa38 (patch) | |
tree | b47cb3bb83c2377234226fb3987ab3320a987dd9 /plugins/common/OAuth1Support.vala | |
parent | ac6e0b731b9f0b2efd392e3309a5c07e2a66adad (diff) | |
parent | e905d8e16eec152d19797937f13ba3cf4b8f8aca (diff) |
Merge branch 'release/debian/0.32.1-1'debian/0.32.1-1
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() { |