From 6834e09485ce2c2b80286565c113bcef7ac72022 Mon Sep 17 00:00:00 2001 From: Pascal Obry Date: Sat, 15 Feb 2014 15:27:01 +0100 Subject: [PATCH] Add support for own client_id, client_secret and redirect_uri. --- README | 55 ++++++++++++++++------------------------------------ cloudfsapi.c | 23 ++++++++++++---------- cloudfsapi.h | 4 +++- cloudfuse.c | 9 +++++++-- 4 files changed, 40 insertions(+), 51 deletions(-) diff --git a/README b/README index 9985252..7f69077 100644 --- a/README +++ b/README @@ -1,17 +1,6 @@ -Cloudfuse is a FUSE application which provides access to Rackspace's -Cloud Files (or any installation of Swift). - -Cloud Files is a remote storage system which is similar in principle to -Amazon S3. It provides a simple RESTful interface to storing and retrieving -objects. - - http://www.rackspacecloud.com/cloud_hosting_products/files - -Swift, the software behind Cloud Files, has been open-sourced as part of the -OpenStack project. - - http://swift.openstack.org/ +HubicFuse is a FUSE application which provides access to Hubic's +cloud files via a mount-point. BUILDING: @@ -30,44 +19,34 @@ BUILDING: make sudo make install - But I'm no autoconf wizard, and there may be dragons lurking there. - - USE: - sudo hubicfuse /mnt/hubic -o username='xxx',password='xxx',noauto_cache,sync_read,allow_other + Your Hubic Cloud configuration can be placed in a file named + $HOME/.cloudfuse. All the following variables are required: - Your Hubic Cloud username and password can be placed in a file - named $HOME/.cloudfuse: username=[Hubic user e-mail] password=[Hubic password] + client_id=[Hubic client id for the registered application] + client_secret=[Hubic client secret for the registered application] + redirect_uri=[Hubic redirect uri as registered for the application] - The following settings are optional: - authurl=[Authentication url - connect to non-Rackspace Swift] - tenant=[Tenant for authentication with Keystone, enables Auth 2.0 API] - password=[Alias for api_key, if using Keystone API] - use_snet=[True to use Rackspace ServiceNet for connections] - cache_timeout=[Seconds for directory caching, default 600] - verify_ssl=[False to disable SSL cert verification] + The you can call hubicfuse: + + sudo hubicfuse /mnt/hubic -o noauto_cache,sync_read,allow_other + + It is possible to pass (or override) some variables on the command line: + + sudo hubicfuse /mnt/hubic \ + -o username='xxx',password='xxx',noauto_cache,sync_read,allow_other + + And finaly, it can be set in /etc/fstab: - Or as mount options in /etc/fstab: hubicfuse /mnt/hubic fuse username=xxx,password=xxx...,user 0 0 It also inherits a number of command-line arguments and mount options from the Fuse framework. The "-h" argument should provide a summary. -EXAMPLE: - - A typical .cloudfuse configuration file for use with OpenStack Essex: - - username=demo - tenant=demo - api_key=supersecret - authurl=http://10.10.0.1:5000/v2.0/tokens - use_openstack=true - - BUGS/SHORTCOMINGS: * rename() doesn't work on directories (and probably never will). diff --git a/cloudfsapi.c b/cloudfsapi.c index 7a442da..68d6d4a 100644 --- a/cloudfsapi.c +++ b/cloudfsapi.c @@ -531,15 +531,15 @@ int safe_json_string(json_object *jobj, char *buffer, char *name) int cloudfs_connect() { - #define HUBIC_TOKEN_URL "https://api.hubic.com/oauth/token" - #define HUBIC_AUTH_URL "https://api.hubic.com/oauth/auth" - #define HUBIC_CRED_URL "https://api.hubic.com/1.0/account/credentials" - #define HUBIC_CLIENT_ID "api_hubic_1366206728U6faUvDSfE1iFImoFAFUIfDRbJytlaY0" - #define HUBIC_CLIENT_SECRET "gXfu3KUIO1K57jUsW7VgKmNEhOWIbFdy7r8Z2xBdZn5K6SMkMmnU4lQUcnRy5E26" - #define HUBIC_REDIRECT_URI "http://localhost:8080" - #define HUBIC_USERNAME (options.username) - #define HUBIC_PASSWORD (options.password) - #define HUBIC_OPTIONS_SIZE 2048 + #define HUBIC_TOKEN_URL "https://api.hubic.com/oauth/token" + #define HUBIC_AUTH_URL "https://api.hubic.com/oauth/auth" + #define HUBIC_CRED_URL "https://api.hubic.com/1.0/account/credentials" + #define HUBIC_CLIENT_ID (options.client_id) + #define HUBIC_CLIENT_SECRET (options.client_secret) + #define HUBIC_REDIRECT_URI (options.redirect_uri) + #define HUBIC_USERNAME (options.username) + #define HUBIC_PASSWORD (options.password) + #define HUBIC_OPTIONS_SIZE 2048 long response = -1; char url[HUBIC_OPTIONS_SIZE]; @@ -547,7 +547,7 @@ int cloudfs_connect() pthread_mutex_lock(&pool_mut); - debugf("Authenticating..."); + debugf("Authenticating... (client_id = '%s')", HUBIC_CLIENT_ID); storage_token[0] = storage_url[0] = '\0'; @@ -577,6 +577,9 @@ int cloudfs_connect() curl_easy_setopt(curl, CURLOPT_URL, url); char *json_str = htmlStringGet(curl); + + debugf ("HUBIC AUTH_URL (req token) result: '%s'\n", json_str); + struct json_object *json_obj; const char *oauth_pattern = "