[ARVADOS] updated: df91e9651a0075415a257be97f0a92be061141d3

git at public.curoverse.com git at public.curoverse.com
Mon Jun 30 11:40:52 EDT 2014


Summary of changes:
 services/api/lib/current_api_client.rb          | 20 ++++++++++----------
 services/api/script/get_anonymous_user_token.rb |  6 +++++-
 2 files changed, 15 insertions(+), 11 deletions(-)

       via  df91e9651a0075415a257be97f0a92be061141d3 (commit)
      from  d19180ce1347611daf4e96d3d357fc3d8ea7904f (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 df91e9651a0075415a257be97f0a92be061141d3
Author: radhika <radhika at curoverse.com>
Date:   Mon Jun 30 11:39:41 2014 -0400

    2659: look for scopes and expires_at when getting anonymous token. also, update create anonymous user to check for group link even when the user exists.

diff --git a/services/api/lib/current_api_client.rb b/services/api/lib/current_api_client.rb
index c558150..94bd2b5 100644
--- a/services/api/lib/current_api_client.rb
+++ b/services/api/lib/current_api_client.rb
@@ -140,18 +140,18 @@ module CurrentApiClient
                                      last_name: 'anonymouspublic')
           $anonymous_user.save!
           $anonymous_user.reload
+        end
 
-          group_perms = Link.where(tail_uuid: anonymous_user_uuid,
-                                   head_uuid: anonymous_group_uuid,
-                                   link_class: 'permission',
-                                   name: 'can_read')
+        group_perms = Link.where(tail_uuid: anonymous_user_uuid,
+                                 head_uuid: anonymous_group_uuid,
+                                 link_class: 'permission',
+                                 name: 'can_read')
 
-          if !group_perms.any?
-            group_perm = Link.create(tail_uuid: anonymous_user_uuid,
-                                   head_uuid: anonymous_group_uuid,
-                                   link_class: 'permission',
-                                   name: 'can_read')
-          end
+        if !group_perms.any?
+          group_perm = Link.create!(tail_uuid: anonymous_user_uuid,
+                                    head_uuid: anonymous_group_uuid,
+                                    link_class: 'permission',
+                                    name: 'can_read')
         end
       end
     end
diff --git a/services/api/script/get_anonymous_user_token.rb b/services/api/script/get_anonymous_user_token.rb
index 76e2088..6964af0 100755
--- a/services/api/script/get_anonymous_user_token.rb
+++ b/services/api/script/get_anonymous_user_token.rb
@@ -27,6 +27,7 @@ def create_api_client_auth
   api_client_auth = ApiClientAuthorization.
     new(user: anonymous_user,
         api_client_id: 0,
+        expires_at: Time.now + 100.years,
         scopes: ['GET /'])
   api_client_auth.save!
   api_client_auth.reload
@@ -34,7 +35,10 @@ end
 
 if get_existing
   api_client_auth = ApiClientAuthorization.
-    where('user_id=?', anonymous_user.id.to_i).first
+    where('user_id=?', anonymous_user.id.to_i).
+    where('expires_at>?', Time.now).
+    select { |auth| auth.scopes == ['GET /'] }.
+    first
 end
 
 # either not a get or no api_client_auth was found

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


hooks/post-receive
-- 




More information about the arvados-commits mailing list