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 +4 -4
- data/app/helpers/application_helper.rb +12 -0
- data/lib/ocean-rails.rb +1 -2
- data/lib/ocean/api_resource.rb +3 -0
- data/lib/ocean/ocean_application_controller.rb +6 -5
- data/lib/ocean/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a61b3ff0ce74f62050af6db2e58870eea435f15
|
4
|
+
data.tar.gz: 119e575e58675abcac2920ab8316bf688a913981
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
data/lib/ocean/api_resource.rb
CHANGED
@@ -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
|
-
|
68
|
-
@auth_api_user_id =
|
69
|
-
@auth_api_user_uri =
|
70
|
-
Thread.current[:username] =
|
71
|
-
@right_restrictions =
|
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
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.
|
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-
|
11
|
+
date: 2014-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|