graphql_authorize 0.3.0 → 0.4.0
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/.gitignore +3 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile.lock +17 -2
- data/config/i18n-tasks.yml +38 -0
- data/config/locales/en.yml +8 -0
- data/graphql_authorize.gemspec +2 -0
- data/lib/graphql_authorize.rb +3 -0
- data/lib/graphql_authorize/auth_adapters/can_can_can.rb +2 -4
- data/lib/graphql_authorize/ext/field_resolve_step.rb +3 -1
- data/lib/graphql_authorize/version.rb +1 -1
- metadata +32 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41357f059b9d65f48c30b401062ec626c961edab225049c1ef92e474df2fea31
|
4
|
+
data.tar.gz: b051cfc4469d002d251ebc1a650365143db03bc51262ce6d4a1a253578df760f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: aae805c749a921ae201dc2e3d6d89e2c628a29b066d2b89964c16a6ff2f06bfa402cd37454c39bcd4ef8ed0dbe8a4c4431a795af9f71f7fda75b3b6680539d53
|
7
|
+
data.tar.gz: 9c8404047d9ea389ef0d3da565cdac4540b6c26a1d2184e1dd4437a08f22fe345a1bd31c89b4dde48aa3eec60097506e73aec1c527bfc9cceece7d519d613af7
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## master
|
4
4
|
|
5
|
+
## 0.4.0
|
6
|
+
|
7
|
+
- [PR [#9](https://github.com/anjlab/graphql_authorize/pull/9)] Implement I18n ([@krider2010][])
|
8
|
+
|
5
9
|
## 0.3.0 (2018-10-09)
|
6
10
|
|
7
11
|
- [PR [#7](https://github.com/DmitryTsepelev/ar_lazy_preload/pull/7)] Remove global exception handler ([@DmitryTsepelev][])
|
@@ -16,3 +20,4 @@
|
|
16
20
|
|
17
21
|
[@DmitryTsepelev]: https://github.com/DmitryTsepelev
|
18
22
|
[@serggl]: https://github.com/serggl
|
23
|
+
[@krider2010]: https://github.com/krider2010
|
data/Gemfile.lock
CHANGED
@@ -1,8 +1,9 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
graphql_authorize (0.
|
4
|
+
graphql_authorize (0.4.0)
|
5
5
|
graphql (>= 1.6)
|
6
|
+
i18n (~> 1.1)
|
6
7
|
|
7
8
|
GEM
|
8
9
|
remote: https://rubygems.org/
|
@@ -16,9 +17,20 @@ GEM
|
|
16
17
|
cancancan (2.2.0)
|
17
18
|
concurrent-ruby (1.0.5)
|
18
19
|
diff-lcs (1.3)
|
20
|
+
erubi (1.7.1)
|
19
21
|
graphql (1.8.10)
|
22
|
+
highline (2.0.0)
|
20
23
|
i18n (1.1.0)
|
21
24
|
concurrent-ruby (~> 1.0)
|
25
|
+
i18n-tasks (0.9.25)
|
26
|
+
activesupport (>= 4.0.2)
|
27
|
+
ast (>= 2.1.0)
|
28
|
+
erubi
|
29
|
+
highline (>= 2.0.0)
|
30
|
+
i18n
|
31
|
+
parser (>= 2.2.3.0)
|
32
|
+
rainbow (>= 2.2.2, < 4.0)
|
33
|
+
terminal-table (>= 1.5.1)
|
22
34
|
jaro_winkler (1.5.1)
|
23
35
|
minitest (5.11.3)
|
24
36
|
parallel (1.12.1)
|
@@ -51,6 +63,8 @@ GEM
|
|
51
63
|
ruby-progressbar (~> 1.7)
|
52
64
|
unicode-display_width (~> 1.0, >= 1.0.1)
|
53
65
|
ruby-progressbar (1.10.0)
|
66
|
+
terminal-table (1.8.0)
|
67
|
+
unicode-display_width (~> 1.1, >= 1.1.1)
|
54
68
|
thread_safe (0.3.6)
|
55
69
|
tzinfo (1.2.5)
|
56
70
|
thread_safe (~> 0.1)
|
@@ -64,10 +78,11 @@ DEPENDENCIES
|
|
64
78
|
bundler (~> 1.16)
|
65
79
|
cancancan (~> 2.0)
|
66
80
|
graphql_authorize!
|
81
|
+
i18n-tasks (~> 0.9.25)
|
67
82
|
pundit
|
68
83
|
rake (~> 10.0)
|
69
84
|
rspec
|
70
85
|
rubocop
|
71
86
|
|
72
87
|
BUNDLED WITH
|
73
|
-
1.16.
|
88
|
+
1.16.6
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# i18n-tasks finds and manages missing and unused translations: https://github.com/glebm/i18n-tasks
|
2
|
+
|
3
|
+
# The "main" locale.
|
4
|
+
base_locale: en
|
5
|
+
|
6
|
+
# Read and write translations.
|
7
|
+
data:
|
8
|
+
# Locale files or `File.find` patterns where translations are read from:
|
9
|
+
read:
|
10
|
+
## Default:
|
11
|
+
# - config/locales/%{locale}.yml
|
12
|
+
|
13
|
+
# Locale files to write new keys to, based on a list of key pattern => file rules. Matched from top to bottom:
|
14
|
+
# `i18n-tasks normalize -p` will force move the keys according to these rules
|
15
|
+
write:
|
16
|
+
## Catch-all default:
|
17
|
+
# - config/locales/%{locale}.yml
|
18
|
+
|
19
|
+
# External locale data (e.g. gems).
|
20
|
+
# This data is not considered unused and is never written to.
|
21
|
+
external:
|
22
|
+
|
23
|
+
yaml:
|
24
|
+
write:
|
25
|
+
# do not wrap lines at 80 characters
|
26
|
+
line_width: -1
|
27
|
+
|
28
|
+
# Find translate calls
|
29
|
+
search:
|
30
|
+
## Paths or `File.find` patterns to search in:
|
31
|
+
paths:
|
32
|
+
- lib/
|
33
|
+
|
34
|
+
## Files or `File.fnmatch` patterns to exclude from search. Some files are always excluded regardless of this setting:
|
35
|
+
exclude:
|
36
|
+
- app/assets/images
|
37
|
+
- app/assets/fonts
|
38
|
+
- app/assets/videos
|
@@ -0,0 +1,8 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
graphql_authorize:
|
4
|
+
auth:
|
5
|
+
canrespond: an object returned by \#auth_adapter_source call does not respond to \#can?
|
6
|
+
arrayargs: \#authorize arguments should be passed as array, e.g. `authorize [:read, Post]`
|
7
|
+
graphql:
|
8
|
+
accessdenied: Access to the field '%{name}' is denied!
|
data/graphql_authorize.gemspec
CHANGED
@@ -26,6 +26,7 @@ Gem::Specification.new do |spec|
|
|
26
26
|
spec.required_ruby_version = ">= 2.3"
|
27
27
|
|
28
28
|
spec.add_dependency "graphql", ">= 1.6"
|
29
|
+
spec.add_dependency "i18n", "~> 1.1"
|
29
30
|
|
30
31
|
spec.add_development_dependency "bundler", "~> 1.16"
|
31
32
|
spec.add_development_dependency "rake", "~> 10.0"
|
@@ -34,4 +35,5 @@ Gem::Specification.new do |spec|
|
|
34
35
|
spec.add_development_dependency "cancancan", "~> 2.0"
|
35
36
|
spec.add_development_dependency "pundit"
|
36
37
|
spec.add_development_dependency "activesupport"
|
38
|
+
spec.add_development_dependency "i18n-tasks", "~> 0.9.25"
|
37
39
|
end
|
data/lib/graphql_authorize.rb
CHANGED
@@ -27,6 +27,9 @@ module GraphqlAuthorize
|
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
|
+
# Default, if not specified, is :en
|
31
|
+
I18n.load_path << Dir[File.expand_path("config/locales") + "/*.yml"]
|
32
|
+
|
30
33
|
GraphQL::Field.include(GraphqlAuthorize::Field)
|
31
34
|
|
32
35
|
GraphQL::Schema::Field.include(GraphqlAuthorize::SchemaField) if supports_class_syntax?
|
@@ -5,13 +5,11 @@ module GraphqlAuthorize
|
|
5
5
|
class CanCanCan < Base
|
6
6
|
def authorize
|
7
7
|
unless field_definition.authorize.is_a?(Array)
|
8
|
-
raise ArgumentError,
|
9
|
-
"#authorize arguments should be passed as array, e.g. `authorize [:read, Post]`"
|
8
|
+
raise ArgumentError, I18n.t("graphql_authorize.auth.arrayargs")
|
10
9
|
end
|
11
10
|
|
12
11
|
unless source.respond_to?(:can?)
|
13
|
-
raise ArgumentError,
|
14
|
-
"an object returned by #auth_adapter_source call does not respond to #can?"
|
12
|
+
raise ArgumentError, I18n.t("graphql_authorize.auth.canrespond")
|
15
13
|
end
|
16
14
|
|
17
15
|
source.can?(*field_definition.authorize)
|
@@ -7,7 +7,9 @@ module GraphqlAuthorize
|
|
7
7
|
if authorized?(field_definition, parent_object, field_args, context)
|
8
8
|
super
|
9
9
|
else
|
10
|
-
GraphQL::ExecutionError.new(
|
10
|
+
GraphQL::ExecutionError.new(
|
11
|
+
I18n.t("graphql_authorize.graphql.accessdenied", name: field_definition.name)
|
12
|
+
)
|
11
13
|
end
|
12
14
|
end
|
13
15
|
# rubocop:enable Metrics/ParameterLists
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql_authorize
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- DmitryTsepelev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-10-
|
11
|
+
date: 2018-10-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: graphql
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.6'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: i18n
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.1'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: bundler
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,6 +136,20 @@ dependencies:
|
|
122
136
|
- - ">="
|
123
137
|
- !ruby/object:Gem::Version
|
124
138
|
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: i18n-tasks
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - "~>"
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: 0.9.25
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - "~>"
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: 0.9.25
|
125
153
|
description: Auth support for ruby-graphql
|
126
154
|
email:
|
127
155
|
- dmitry.a.tsepelev@gmail.com
|
@@ -140,6 +168,8 @@ files:
|
|
140
168
|
- Rakefile
|
141
169
|
- bin/console
|
142
170
|
- bin/setup
|
171
|
+
- config/i18n-tasks.yml
|
172
|
+
- config/locales/en.yml
|
143
173
|
- gemfiles/graphql-1.6.gemfile
|
144
174
|
- gemfiles/graphql-1.7.gemfile
|
145
175
|
- gemfiles/graphql-1.8.gemfile
|