mirror of
https://github.com/TurboGit/hubicfuse.git
synced 2026-08-01 18:32:23 +02:00
Add support for own client_id, client_secret and redirect_uri.
This commit is contained in:
@@ -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).
|
||||
|
||||
+13
-10
@@ -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 = "<input type=\"hidden\" name=\"oauth\" value=\"";
|
||||
|
||||
+3
-1
@@ -29,6 +29,9 @@ typedef struct options {
|
||||
char password[OPTION_SIZE];
|
||||
char cache_timeout[OPTION_SIZE];
|
||||
char verify_ssl[OPTION_SIZE];
|
||||
char client_id[OPTION_SIZE];
|
||||
char client_secret[OPTION_SIZE];
|
||||
char redirect_uri[OPTION_SIZE];
|
||||
} FuseOptions;
|
||||
|
||||
void cloudfs_init();
|
||||
@@ -48,4 +51,3 @@ void cloudfs_free_dir_list(dir_entry *dir_list);
|
||||
|
||||
void debugf(char *fmt, ...);
|
||||
#endif
|
||||
|
||||
|
||||
+7
-2
@@ -426,6 +426,9 @@ FuseOptions options = {
|
||||
.password = "",
|
||||
.cache_timeout = "600",
|
||||
.verify_ssl = "true",
|
||||
.client_id = "",
|
||||
.client_secret = "",
|
||||
.redirect_uri = ""
|
||||
};
|
||||
|
||||
int parse_option(void *data, const char *arg, int key, struct fuse_args *outargs)
|
||||
@@ -433,7 +436,10 @@ int parse_option(void *data, const char *arg, int key, struct fuse_args *outargs
|
||||
if (sscanf(arg, " username = %[^\r\n ]", options.username) ||
|
||||
sscanf(arg, " password = %[^\r\n ]", options.password) ||
|
||||
sscanf(arg, " cache_timeout = %[^\r\n ]", options.cache_timeout) ||
|
||||
sscanf(arg, " verify_ssl = %[^\r\n ]", options.verify_ssl))
|
||||
sscanf(arg, " verify_ssl = %[^\r\n ]", options.verify_ssl) ||
|
||||
sscanf(arg, " client_id = %[^\r\n ]", options.client_id) ||
|
||||
sscanf(arg, " client_secret = %[^\r\n ]", options.client_secret) ||
|
||||
sscanf(arg, " redirect_uri = %[^\r\n ]", options.redirect_uri))
|
||||
return 0;
|
||||
if (!strcmp(arg, "-f") || !strcmp(arg, "-d") || !strcmp(arg, "debug"))
|
||||
cloudfs_debug(1);
|
||||
@@ -515,4 +521,3 @@ int main(int argc, char **argv)
|
||||
pthread_mutex_init(&dmut, NULL);
|
||||
return fuse_main(args.argc, args.argv, &cfs_oper, &options);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user