[shotwell] OAuth1: Fix upload signing
- From: Jens Georg <jensgeorg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [shotwell] OAuth1: Fix upload signing
- Date: Thu, 16 Nov 2017 20:46:41 +0000 (UTC)
commit e5abe03c52172f6bdb649c4247d8face70646bdc
Author: Jens Georg <mail jensge org>
Date: Thu Nov 16 21:44:49 2017 +0100
OAuth1: Fix upload signing
plugins/common/RESTSupport.vala | 16 ++++++++++++----
1 files changed, 12 insertions(+), 4 deletions(-)
---
diff --git a/plugins/common/RESTSupport.vala b/plugins/common/RESTSupport.vala
index 6568bef..14e5962 100644
--- a/plugins/common/RESTSupport.vala
+++ b/plugins/common/RESTSupport.vala
@@ -914,7 +914,8 @@ namespace OAuth1 {
this.consumer_secret = consumer_secret;
}
- public void sign_transaction(Publishing.RESTSupport.Transaction txn) {
+ public string sign_transaction(Publishing.RESTSupport.Transaction txn,
+ Publishing.RESTSupport.Argument[]? extra_arguments = null) {
string http_method = txn.get_method().to_string();
debug("signing transaction with parameters:");
@@ -922,6 +923,10 @@ namespace OAuth1 {
Publishing.RESTSupport.Argument[] base_string_arguments = txn.get_arguments();
+ foreach (var arg in extra_arguments) {
+ base_string_arguments += arg;
+ }
+
Publishing.RESTSupport.Argument[] sorted_args =
Publishing.RESTSupport.Argument.sort(base_string_arguments);
@@ -957,7 +962,7 @@ namespace OAuth1 {
debug("signature = '%s'", signature);
- txn.add_argument("oauth_signature", signature);
+ return signature;
}
public void set_request_phase_credentials(string token, string secret) {
@@ -1043,7 +1048,8 @@ namespace OAuth1 {
public override void execute() throws Spit.Publishing.PublishingError {
- ((Session) get_parent_session()).sign_transaction(this);
+ var signature = ((Session) get_parent_session()).sign_transaction(this);
+ add_argument("oauth_signature", signature);
base.execute();
}
@@ -1078,7 +1084,9 @@ namespace OAuth1 {
}
public void authorize() {
- session.sign_transaction(this);
+ var signature = session.sign_transaction(this, auth_header_fields);
+ add_authorization_header_field("oauth_signature", signature);
+
string authorization_header = get_authorization_header_string();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]