← Back to team overview

deja-dup-team team mailing list archive

[Merge] lp:~jjmartinez/deja-dup/coudfiles-custom-auth-url into lp:deja-dup

 

Juan J. Martínez has proposed merging lp:~jjmartinez/deja-dup/coudfiles-custom-auth-url into lp:deja-dup.

Requested reviews:
  Déjà Dup Developers (deja-dup-hackers)

For more details, see:
https://code.launchpad.net/~jjmartinez/deja-dup/coudfiles-custom-auth-url/+merge/109589

This change allows the user to enter a custom authentication URL to fix +bug 793997:

 - Uses Rackspace US auth URL by default
 - Allows the user to enter a custom auth URL, so Rackspace UK or an OpenStack Object Storage instance can be used

The UI can be improved, but I think this is a first step from a hard coded auth URL to a more flexible implementation using the available functionality on Duplicity.

I'd like to help to improve the UI, but my knowledge of Vala is limited and after reading the code it looks like it will require a good amount of code additions.

The code has been tested with Ubuntu 12.04 and OpenStack Object Storage 1.4.3.

References:

 - bug 793997: https://bugs.launchpad.net/deja-dup/+bug/793997
 - Auth URLs for Cloud Files: http://docs.rackspace.com/files/api/v1/cf-devguide/content/Authentication-d1e639.html
 - Setting the CLOUDFILES_AUTHURL env variable in Duplicity: http://blog.chmouel.com/2011/01/06/backup-with-duplicity-on-rackspace-cloudfiles-including-uk-script/
 - OpenStack Objects Storage is compatible with Cloud Files: http://openstack.org/software/openstack-storage/

-- 
https://code.launchpad.net/~jjmartinez/deja-dup/coudfiles-custom-auth-url/+merge/109589
Your team Déjà Dup Developers is requested to review the proposed merge of lp:~jjmartinez/deja-dup/coudfiles-custom-auth-url into lp:deja-dup.
=== modified file 'common/BackendRackspace.vala'
--- common/BackendRackspace.vala	2012-03-21 03:01:36 +0000
+++ common/BackendRackspace.vala	2012-06-11 09:23:16 +0000
@@ -24,8 +24,8 @@
 public const string RACKSPACE_ROOT = "Rackspace";
 public const string RACKSPACE_USERNAME_KEY = "username";
 public const string RACKSPACE_CONTAINER_KEY = "container";
-
-const string RACKSPACE_SERVER = "auth.api.rackspacecloud.com";
+public const string RACKSPACE_AUTH_URL_KEY = "auth-url";
+public const string RACKSPACE_AUTH_URL = "https://auth.api.rackspacecloud.com/v1.0";;
 
 public class BackendRackspace : Backend
 {
@@ -47,7 +47,8 @@
 
   public override async bool is_ready(out string when) {
     when = _("Backup will begin when a network connection becomes available.");
-    return yield Network.get().can_reach ("http://%s/".printf(RACKSPACE_SERVER));
+    var check_url = auth_url == null ? RACKSPACE_AUTH_URL : auth_url;
+    return yield Network.get().can_reach(check_url);
   }
 
   public override string get_location(ref bool as_root)
@@ -72,12 +73,16 @@
       return _("%s on Rackspace Cloud Files").printf(container);
   }
 
+  string settings_auth_url;
+  string auth_url;
   string settings_id;
   string id;
   string secret_key;
   public override async void get_envp() throws Error
   {
     var settings = get_settings(RACKSPACE_ROOT);
+    settings_auth_url = settings.get_string(RACKSPACE_AUTH_URL_KEY);
+    auth_url = settings_auth_url == null ? RACKSPACE_AUTH_URL : settings_auth_url;
     settings_id = settings.get_string(RACKSPACE_USERNAME_KEY);
     id = settings_id == null ? "" : settings_id;
 
@@ -90,7 +95,8 @@
     if (id != "") {
       // First, try user's keyring
       secret_key = null;
-      GnomeKeyring.find_network_password(id, null, RACKSPACE_SERVER, null, "https",
+      var uri = DejaDupDecodedUri.decode_uri(auth_url);
+      GnomeKeyring.find_network_password(id, null, uri.host, null, "https",
                                          null, 0, found_password);
     }
     else
@@ -128,7 +134,8 @@
     if (remember != PasswordSave.NEVER) {
       string where = (remember == PasswordSave.FOR_SESSION) ?
                      "session" : GnomeKeyring.DEFAULT;
-      GnomeKeyring.set_network_password(where, id, null, RACKSPACE_SERVER, null,
+      var uri = DejaDupDecodedUri.decode_uri(auth_url);
+      GnomeKeyring.set_network_password(where, id, null, uri.host, null,
                                         "https", null, 0, secret_key,
                                         save_password_callback);
     }
@@ -153,8 +160,11 @@
     var settings = get_settings(RACKSPACE_ROOT);
     if (id != settings_id)
       settings.set_string(RACKSPACE_USERNAME_KEY, id);
+    if (auth_url != settings_auth_url)
+      settings.set_string(RACKSPACE_AUTH_URL_KEY, auth_url);
 
     List<string> envp = new List<string>();
+    envp.append("CLOUDFILES_AUTHURL=%s".printf(auth_url));
     envp.append("CLOUDFILES_USERNAME=%s".printf(id));
     envp.append("CLOUDFILES_APIKEY=%s".printf(secret_key));
     envp_ready(true, envp);

=== modified file 'data/org.gnome.DejaDup.gschema.xml.in'
--- data/org.gnome.DejaDup.gschema.xml.in	2011-08-31 03:50:06 +0000
+++ data/org.gnome.DejaDup.gschema.xml.in	2012-06-11 09:23:16 +0000
@@ -101,6 +101,11 @@
       <_summary>Your Rackspace username</_summary>
       <_description>This is your username for the Rackspace Cloud Files service.</_description>
     </key>
+    <key name="auth-url" type="s">
+      <default>'https://auth.api.rackspacecloud.com/v1.0'</default> <!-- Default to Rackspace US auth URL -->
+      <_summary>Rackspace authentication URL</_summary>
+      <_description>This is the Rackspace Cloud Files authentication service URL.</_description>
+    </key>
   </schema>
   <schema id="org.gnome.DejaDup.U1" path="/org/gnome/deja-dup/u1/">
     <key name="folder" type="s">

=== modified file 'widgets/ConfigLocationRackspace.vala'
--- widgets/ConfigLocationRackspace.vala	2011-08-13 04:16:21 +0000
+++ widgets/ConfigLocationRackspace.vala	2012-06-11 09:23:16 +0000
@@ -28,6 +28,8 @@
   }
 
   construct {
+    add_widget(_("_Authentication URL"),
+               new ConfigEntry(DejaDup.RACKSPACE_AUTH_URL_KEY, DejaDup.RACKSPACE_ROOT));
     add_widget(_("_Username"),
                new ConfigEntry(DejaDup.RACKSPACE_USERNAME_KEY, DejaDup.RACKSPACE_ROOT));
     add_widget(_("_Container"),