[ARVADOS] updated: c8eda6129bb6a40475157e4816d30fa4d2d66aed
git at public.curoverse.com
git at public.curoverse.com
Thu Jun 12 14:31:46 EDT 2014
Summary of changes:
services/api/script/get_anonymous_user_token.rb | 46 +++++++++++++++++++++++++
1 file changed, 46 insertions(+)
create mode 100755 services/api/script/get_anonymous_user_token.rb
via c8eda6129bb6a40475157e4816d30fa4d2d66aed (commit)
from 72fab72c18b18af90b7a820b0b6cfd881ced987c (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
commit c8eda6129bb6a40475157e4816d30fa4d2d66aed
Author: radhika <radhika at curoverse.com>
Date: Thu Jun 12 14:30:51 2014 -0400
2659: script to create or get anonymous user token
diff --git a/services/api/script/get_anonymous_user_token.rb b/services/api/script/get_anonymous_user_token.rb
new file mode 100755
index 0000000..081d6f6
--- /dev/null
+++ b/services/api/script/get_anonymous_user_token.rb
@@ -0,0 +1,46 @@
+#!/usr/bin/env ruby
+
+# Get or Create an anonymous user token.
+# If get option is used, an existing anonymous user token is returned. If none exist, one is created.
+# If the get option is omitted, a new token is created and returned.
+
+require 'trollop'
+
+opts = Trollop::options do
+ banner ''
+ banner "Usage: get_anonymous_user_token "
+ banner ''
+ opt :get, <<-eos
+Get an existing anonymous user token. If no such token exists \n
+or if this option is omitted, a new token is created and returned.
+ eos
+end
+
+create_or_get = opts[:get]
+
+require File.dirname(__FILE__) + '/../config/environment'
+
+include ApplicationHelper
+act_as_system_user
+
+def create_api_client_auth
+ api_client_auth = ApiClientAuthorization.
+ new(user: anonymous_user,
+ api_client_id: 0,
+ scopes: ['GET /'])
+ api_client_auth.save!
+ api_client_auth.reload
+end
+
+if create_or_get
+ api_client_auth = ApiClientAuthorization.
+ where('user_id=?', anonymous_user.id.to_i).first
+end
+
+# either not a get or no api_client_auth was found
+if !api_client_auth
+ api_client_auth = create_api_client_auth
+end
+
+# print it to the console
+puts api_client_auth.api_token
-----------------------------------------------------------------------
hooks/post-receive
--
More information about the arvados-commits
mailing list