graphql-guard 1.3.0 → 1.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -8
- data/CHANGELOG.md +4 -0
- data/Gemfile +1 -1
- data/README.md +12 -3
- data/{graphql-1.8.gemfile → graphql-latest.gemfile} +1 -1
- data/lib/graphql/guard.rb +17 -7
- data/lib/graphql/guard/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fbde911695d5151407974b87a6ddd6ab4e02c726685ed35c1c59ad270a541a3c
|
4
|
+
data.tar.gz: 877dfa834f5b5880fe11f020567d55dfda0e8e012e3ea3d6c2a4e8acb9ed6ce7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a485275f3e04a296a2fe0b5362aa8c15ee6002edab671f817758f4540ba05761675532d5b05b0ded05c78c05fd974e44c145085b8237aab59fb3df023e421a1
|
7
|
+
data.tar.gz: 52cade5337f95be53a0200663ecbe039a4026f63d21d54069b243676a65a23c594ada684defe85c194217caae0d1807ca487015196560a75a5fe2eab4adf786a
|
data/.travis.yml
CHANGED
@@ -6,24 +6,24 @@ matrix:
|
|
6
6
|
- gemfile: graphql-1.7.gemfile
|
7
7
|
env: GRAPHQL_RUBY_VERSION=1_7 CI=true
|
8
8
|
rvm: 2.3.8
|
9
|
-
- gemfile: graphql-
|
10
|
-
env: GRAPHQL_RUBY_VERSION=
|
9
|
+
- gemfile: graphql-latest.gemfile
|
10
|
+
env: GRAPHQL_RUBY_VERSION=LATEST CI=true
|
11
11
|
rvm: 2.3.8
|
12
12
|
- gemfile: graphql-1.7.gemfile
|
13
13
|
env: GRAPHQL_RUBY_VERSION=1_7 CI=true
|
14
14
|
rvm: 2.4.5
|
15
|
-
- gemfile: graphql-
|
16
|
-
env: GRAPHQL_RUBY_VERSION=
|
15
|
+
- gemfile: graphql-latest.gemfile
|
16
|
+
env: GRAPHQL_RUBY_VERSION=LATEST CI=true
|
17
17
|
rvm: 2.4.5
|
18
18
|
- gemfile: graphql-1.7.gemfile
|
19
19
|
env: GRAPHQL_RUBY_VERSION=1_7 CI=true
|
20
20
|
rvm: 2.5.7
|
21
|
-
- gemfile: graphql-
|
22
|
-
env: GRAPHQL_RUBY_VERSION=
|
21
|
+
- gemfile: graphql-latest.gemfile
|
22
|
+
env: GRAPHQL_RUBY_VERSION=LATEST CI=true
|
23
23
|
rvm: 2.5.7
|
24
24
|
- gemfile: graphql-1.7.gemfile
|
25
25
|
env: GRAPHQL_RUBY_VERSION=1_7 CI=true
|
26
26
|
rvm: 2.6.5
|
27
|
-
- gemfile: graphql-
|
28
|
-
env: GRAPHQL_RUBY_VERSION=
|
27
|
+
- gemfile: graphql-latest.gemfile
|
28
|
+
env: GRAPHQL_RUBY_VERSION=LATEST CI=true
|
29
29
|
rvm: 2.6.5
|
data/CHANGELOG.md
CHANGED
@@ -12,6 +12,10 @@ that you can set version constraints properly.
|
|
12
12
|
|
13
13
|
* WIP
|
14
14
|
|
15
|
+
#### [v1.3.1](https://github.com/exAspArk/graphql-guard/compare/v1.3.0...v1.3.1) – 2020-01-22
|
16
|
+
|
17
|
+
* `Fixed`: compatibility with `graphql` gem version 1.10. [#36](https://github.com/exAspArk/graphql-guard/pull/36)
|
18
|
+
|
15
19
|
#### [v1.3.0](https://github.com/exAspArk/graphql-guard/compare/v1.2.2...v1.3.0) – 2019-10-24
|
16
20
|
|
17
21
|
* `Added`: More descriptive default error message for `NotAuthorizedError`. [#32](https://github.com/exAspArk/graphql-guard/pull/32)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -120,11 +120,20 @@ class <b>GraphqlPolicy</b>
|
|
120
120
|
end
|
121
121
|
</pre>
|
122
122
|
|
123
|
-
With `graphql-ruby` gem version >= 1.8 and class-based type definitions, `
|
123
|
+
With `graphql-ruby` gem version >= 1.8 and class-based type definitions, use `camelCased` field names in the policy object.
|
124
|
+
You'd also need to use `type.metadata` (related to [rmosolgo/graphql-ruby#1429](https://github.com/rmosolgo/graphql-ruby/issues/1429)) to get the type class:
|
124
125
|
|
125
126
|
<pre>
|
126
|
-
|
127
|
-
RULES
|
127
|
+
class GraphqlPolicy
|
128
|
+
RULES = {
|
129
|
+
MutationType => {
|
130
|
+
<b>createPost</b>: ->(obj, args, cts) { ctx[:current_user].admin? }
|
131
|
+
}
|
132
|
+
}
|
133
|
+
|
134
|
+
def self.guard(type, field)
|
135
|
+
RULES.dig(<b>type.metadata[:type_class]</b>, field)
|
136
|
+
end
|
128
137
|
end
|
129
138
|
</pre>
|
130
139
|
|
data/lib/graphql/guard.rb
CHANGED
@@ -19,13 +19,7 @@ module GraphQL
|
|
19
19
|
|
20
20
|
def use(schema_definition)
|
21
21
|
schema_definition.instrument(:field, self)
|
22
|
-
schema_definition
|
23
|
-
def default_filter
|
24
|
-
GraphQL::Filter.new(except: default_mask).merge(only: ->(schema_member, ctx) {
|
25
|
-
schema_member.metadata[:mask] ? schema_member.metadata[:mask].call(ctx) : true
|
26
|
-
})
|
27
|
-
end
|
28
|
-
end
|
22
|
+
add_schema_masking!(schema_definition)
|
29
23
|
end
|
30
24
|
|
31
25
|
def instrument(type, field)
|
@@ -55,6 +49,22 @@ module GraphQL
|
|
55
49
|
|
56
50
|
private
|
57
51
|
|
52
|
+
def add_schema_masking!(schema_definition)
|
53
|
+
default_filter_proc = Proc.new do
|
54
|
+
def default_filter
|
55
|
+
GraphQL::Filter.new(except: default_mask).merge(only: ->(schema_member, ctx) {
|
56
|
+
schema_member.metadata[:mask] ? schema_member.metadata[:mask].call(ctx) : true
|
57
|
+
})
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
if schema_definition.is_a?(Class) # GraphQL-Ruby version >= 1.10
|
62
|
+
schema_definition.class_eval(&default_filter_proc)
|
63
|
+
else
|
64
|
+
schema_definition.target.instance_eval(&default_filter_proc)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
58
68
|
def policy_object_guard(type, field_name)
|
59
69
|
policy_object && policy_object.guard(type, field_name)
|
60
70
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-guard
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.
|
4
|
+
version: 1.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- exAspArk
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -92,8 +92,8 @@ files:
|
|
92
92
|
- bin/console
|
93
93
|
- bin/setup
|
94
94
|
- graphql-1.7.gemfile
|
95
|
-
- graphql-1.8.gemfile
|
96
95
|
- graphql-guard.gemspec
|
96
|
+
- graphql-latest.gemfile
|
97
97
|
- lib/graphql/guard.rb
|
98
98
|
- lib/graphql/guard/testing.rb
|
99
99
|
- lib/graphql/guard/version.rb
|