ocean-rails 2.8.0 → 2.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c40e04d9a10d45f336d5c870c88bb78520d5fc90
4
- data.tar.gz: 42d04e38d27d92bd906daeca2d817a5dc80c8ddb
3
+ metadata.gz: 9a61b3ff0ce74f62050af6db2e58870eea435f15
4
+ data.tar.gz: 119e575e58675abcac2920ab8316bf688a913981
5
5
  SHA512:
6
- metadata.gz: 0ce76c663f2a663a91d6262f73f98e9e99a1f834053731ac66712a429c159f9a3ab6d88d32c0f338913d17bf288fd13a32abbbfdd539698a4bcbd75e64389c90
7
- data.tar.gz: 97fd6522add6458b8e98e1801ee66f286a984f37484da1351c1b8bf7825361decdf86f2f552992839c544176fe3ef4bfe791046a700f09434e348fdab079cf25
6
+ metadata.gz: 619aa4bbbb4a6897d04292337b2e1f81acba21d5346a0f7e9d11350ffdd868648cd1009bbd416c4f85de040d957b5f3a4e55937545c88ae53db858dc31652bdc
7
+ data.tar.gz: 296feb56d1e75d9f83c40d69e3e21c3f22aeff6ec0071d54c2d477e9fa6c9fa42a758221a0f2552db38c21937a501d4c38a32b04c9f8f78a9727c3bf5898b88a
@@ -31,4 +31,16 @@ module ApplicationHelper
31
31
  end
32
32
  end
33
33
 
34
+
35
+ #
36
+ # View helper predicates to determine whether the ApiUser belongs
37
+ # to one or more of a list of Groups.
38
+ #
39
+ def member_of_group?(*names)
40
+ @group_names && @group_names.intersect?(names.to_set)
41
+ end
42
+
43
+ def superuser?
44
+ member_of_group?("Superusers")
45
+ end
34
46
  end
data/lib/ocean-rails.rb CHANGED
@@ -50,6 +50,7 @@ def permit_with(status, user_id: 123, creator_uri: "https://api.example.com/v1/a
50
50
  'type' => 'application/json'}}}}))
51
51
  end
52
52
 
53
+
53
54
  #
54
55
  # For stubbing failed authorisation calls. Makes <tt>Api.permitted?</tt> return the
55
56
  # given status and a body containing a standard API error with the given error messages.
@@ -73,5 +74,3 @@ def add_right_restrictions(rel, restrictions)
73
74
  end
74
75
  rel
75
76
  end
76
-
77
-
@@ -40,6 +40,9 @@ module ApiResource
40
40
  # to calculate OFFSET and LIMIT. The default +page_size+ for a resource class can
41
41
  # also be declared using +ocean_resource_model+.
42
42
  #
43
+ # Right restrictions, if provided, will be added to the relation before it is
44
+ # returned.
45
+ #
43
46
  def collection(bag={})
44
47
  collection_internal bag, bag[:group], bag[:search], bag[:page], bag[:page_size],
45
48
  bag['_right_restrictions']
@@ -64,12 +64,13 @@ module OceanApplicationController
64
64
  qs = Api.authorization_string(@@extra_actions, controller_name, action_name)
65
65
  response = Api.permitted?(@x_api_token, query: qs)
66
66
  if response.status == 200
67
- @authentication = response.body['authentication']
68
- @auth_api_user_id = @authentication['user_id'] # Deprecate and remove
69
- @auth_api_user_uri = @authentication['_links']['creator']['href'] # Keep
70
- Thread.current[:username] = @authentication['username']
71
- @right_restrictions = @authentication['right']
67
+ a = response.body['authentication']
68
+ @auth_api_user_id = a['user_id'] # Deprecate and remove
69
+ @auth_api_user_uri = a['_links']['creator']['href'] # Keep
70
+ Thread.current[:username] = a['username']
71
+ @right_restrictions = a['right']
72
72
  params['_right_restrictions'] = @right_restrictions if @right_restrictions
73
+ @group_names = a['group_names'].to_set if a['group_names']
73
74
  return true
74
75
  end
75
76
  error_messages = response.body['_api_error']
data/lib/ocean/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ocean
2
- VERSION = "2.8.0"
2
+ VERSION = "2.8.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocean-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.0
4
+ version: 2.8.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Bengtson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-03-18 00:00:00.000000000 Z
11
+ date: 2014-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: typhoeus