[ARVADOS] updated: 1.1.3-324-g9151ad6

Git user git at public.curoverse.com
Wed Apr 4 22:21:22 EDT 2018


Summary of changes:
 services/api/script/get_anonymous_user_token.rb | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

       via  9151ad624bef1ae076940298c6890deadd79e2dd (commit)
      from  c48ed6487b9148269f25f6733a1d4f1860b8ea72 (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 9151ad624bef1ae076940298c6890deadd79e2dd
Author: Ward Vandewege <wvandewege at veritasgenetics.com>
Date:   Wed Apr 4 22:19:32 2018 -0400

    api server: get_anonymous_user_token script
    
    * bugfix: always return the token (the script would sometimes fail with
    an error message that it couldn't call api_token on a Hash)
    * new feature: allow supplying of the token to be created via a command
    line argument.
    
    No issue #
    
    Arvados-DCO-1.1-Signed-off-by: Ward Vandewege <wvandewege at veritasgenetics.com>

diff --git a/services/api/script/get_anonymous_user_token.rb b/services/api/script/get_anonymous_user_token.rb
index 7b146fc..96619ef 100755
--- a/services/api/script/get_anonymous_user_token.rb
+++ b/services/api/script/get_anonymous_user_token.rb
@@ -17,23 +17,40 @@ opts = Trollop::options do
 Get an existing anonymous user token. If no such token exists \
 or if this option is omitted, a new token is created and returned.
   eos
+  opt :token, "token to create (optional)", :type => :string
 end
 
 get_existing = opts[:get]
+supplied_token = opts[:token]
 
 require File.dirname(__FILE__) + '/../config/environment'
 
 include ApplicationHelper
 act_as_system_user
 
-def create_api_client_auth
+def create_api_client_auth(supplied_token=nil)
+
+  # If token is supplied, verify that it indeed is a superuser token
+  if supplied_token
+    api_client_auth = ApiClientAuthorization.
+      where(api_token: supplied_token).
+      first
+    if !api_client_auth
+      # fall through to create a token
+    else
+      raise "Token exists, aborting!"
+    end
+  end
+
   api_client_auth = ApiClientAuthorization.
     new(user: anonymous_user,
         api_client_id: 0,
         expires_at: Time.now + 100.years,
-        scopes: ['GET /'])
+        scopes: ['GET /'],
+        api_token: supplied_token)
   api_client_auth.save!
   api_client_auth.reload
+  api_client_auth
 end
 
 if get_existing
@@ -46,7 +63,7 @@ end
 
 # either not a get or no api_client_auth was found
 if !api_client_auth
-  api_client_auth = create_api_client_auth
+  api_client_auth = create_api_client_auth(supplied_token)
 end
 
 # print it to the console

-----------------------------------------------------------------------


hooks/post-receive
-- 




More information about the arvados-commits mailing list