action_policy-graphql 0.2.0 → 0.5.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: da60e0290bedb6652f75804bf0b54eb995c1a85708d35ec486b46022604c13d2
4
- data.tar.gz: c996102f26404ba808fd0a6b5d927f3509c45ba799acc5c1147e20f7e62bb76d
3
+ metadata.gz: b5ed86f1884fc8a9468ed78e7476afc81cf68af0f65a549df4e213f5ab50b53f
4
+ data.tar.gz: 1991a6c3c2414a85bf3738cbdc600fda90d989a059f613200445d6b1d2c47c9e
5
5
  SHA512:
6
- metadata.gz: c344fff8978dc691b1c820e01790234ef472779592bc70b20b5ef9fa0dbac9cc3075893ad299270396b4be69ed7a7c3c54dc502dde39e3c6fedd11049f2007d7
7
- data.tar.gz: 667b4957e8400858eaff8544508cc04482ad90ada14d5f2839910a1ecc29ca6987f3906cf1a111222d81f0d06cc0475884115ddbbac564a554c17200f5bf60cf
6
+ metadata.gz: f7a9012c86bcaad3c1220a7f9621655f3ae3ecc7f314672bf58c3f60d09112aa9605f3c361259bc8a7fb39d147ca696409ca20bb6fe92cf88c0cf1bc8c90d5a0
7
+ data.tar.gz: 967fa7b9dfc0638469744b810b0329f703eacebd6ba66f960448953b172476c183d1bda2e25841c61e963da6bbf8e091243fce0bb0c0409e3c3b53a38d1bc47b
@@ -2,6 +2,47 @@
2
2
 
3
3
  ## master (unreleased)
4
4
 
5
+ ## 0.5.0 (2020-10-07)
6
+
7
+ - Add `preauthorize_mutation_raise_exception` configuration parameter. ([@palkan][])
8
+
9
+ Similar to `preauthorize_raise_exception` but only for mutations.
10
+ Fallbacks to `preauthorize_raise_exception` unless explicitly specified.
11
+
12
+ - Add `preauthorize_raise_exception` configuration parameter. ([@palkan][])
13
+
14
+ Similar to `authorize_raise_exception` but for `preauthorize: true` fields.
15
+ Fallbacks to `authorize_raise_exception` unless explicitly specified.
16
+
17
+ - Add ability to specify custom field options for `expose_authorization_rules`. ([@bibendi][])
18
+
19
+ Now you can add additional options for underflying `field` call via `field_options` parameter:
20
+
21
+ ```ruby
22
+ expose_authorization_rules :show?, field_options: {camelize: false}
23
+
24
+ # equals to
25
+ field :can_show, ActionPolicy::GraphQL::Types::AuthorizationResult, null: false, camelize: false
26
+ ```
27
+
28
+ ## 0.4.0 (2020-03-11)
29
+
30
+ - **Require Ruby 2.5+**. ([@palkan][])
31
+
32
+ - Add `authorized_field: *` option to perform authorization on the base of the upper object policy prior to resolving fields. ([@sponomarev][])
33
+
34
+ ## 0.3.2 (2019-12-12)
35
+
36
+ - Fix compatibility with Action Policy 0.4.0 ([@haines][])
37
+
38
+ ## 0.3.1 (2019-10-23)
39
+
40
+ - Add support for using Action Policy methods in `self.authorized?`. ([@palkan][])
41
+
42
+ ## 0.3.0 (2019-10-21)
43
+
44
+ - Add `preauthorize: *` option to perform authorization prior to resolving fields. ([@palkan][])
45
+
5
46
  ## 0.2.0 (2019-08-15)
6
47
 
7
48
  - Add ability to specify a field name explicitly. ([@palkan][])
@@ -22,3 +63,6 @@ Action Policy helpers there.
22
63
  - Initial version. ([@palkan][])
23
64
 
24
65
  [@palkan]: https://github.com/palkan
66
+ [@haines]: https://github.com/haines
67
+ [@sponomarev]: https://github.com/sponomarev
68
+ [@bibendi]: https://github.com/bibendi
data/README.md CHANGED
@@ -1,5 +1,6 @@
1
1
  [![Gem Version](https://badge.fury.io/rb/action_policy-graphql.svg)](https://badge.fury.io/rb/action_policy-graphql)
2
- [![Build Status](https://travis-ci.org/palkan/action_policy-graphql.svg?branch=master)](https://travis-ci.org/palkan/action_policy-graphql)
2
+ ![Build](https://github.com/palkan/action_policy-graphql/workflows/Build/badge.svg)
3
+ ![JRuby Build](https://github.com/palkan/action_policy-graphql/workflows/JRuby%20Build/badge.svg)
3
4
  [![Documentation](https://img.shields.io/badge/docs-link-brightgreen.svg)](https://actionpolicy.evilmartians.io/#/graphql)
4
5
 
5
6
  # Action Policy GraphQL
@@ -7,9 +8,10 @@
7
8
  This gem provides an integration for using [Action Policy](https://github.com/palkan/action_policy) as an authorization framework for GraphQL applications (built with [`graphql` ruby gem](https://graphql-ruby.org)).
8
9
 
9
10
  This integration includes the following features:
11
+
10
12
  - Fields & mutations authorization
11
13
  - List and connections scoping
12
- - [**Exposing permissions/authorization rules in the API**](https://dev.to/evilmartians/exposing-permissions-in-graphql-apis-with-action-policy-1mfh).
14
+ - [**Exposing permissions/authorization rules in the API**](https://evilmartians.com/chronicles/exposing-permissions-in-graphql-apis-with-action-policy).
13
15
 
14
16
  📑 [Documentation](https://actionpolicy.evilmartians.io/#/graphql)
15
17
 
@@ -21,13 +23,9 @@ This integration includes the following features:
21
23
  Add this line to your application's Gemfile:
22
24
 
23
25
  ```ruby
24
- gem "action_policy-graphql", "~> 0.1"
26
+ gem "action_policy-graphql"
25
27
  ```
26
28
 
27
- And then execute:
28
-
29
- $ bundle
30
-
31
29
  ## Usage
32
30
 
33
31
  **NOTE:** this is a quick overview of the functionality provided by the gem. For more information see the [documentation](https://actionpolicy.evilmartians.io/#/graphql).
@@ -80,6 +78,8 @@ end
80
78
 
81
79
  You can customize the authorization options, e.g. `authorize: {to: :preview?, with: CustomPolicy}`.
82
80
 
81
+ If you don't want to raise an exception but return a null instead, you should set a `raise: false` option.
82
+
83
83
  ### `authorized_scope: *`
84
84
 
85
85
  You can add `authorized_scope: true` option to the field (list or _connection_ field) to
@@ -96,6 +96,68 @@ class CityType < ::Common::Graphql::Type
96
96
  end
97
97
  ```
98
98
 
99
+ **NOTE:** you cannot use `authorize: *` and `authorized_scope: *` at the same time but you can combine `preauthorize: *` or `authorize_field: *` with `authorized_scope: *`.
100
+
101
+ ### `preauthorize: *`
102
+
103
+ If you want to perform authorization before resolving the field value, you can use `preauthorize: *` option:
104
+
105
+ ```ruby
106
+ field :homes, [Home], null: false, preauthorize: {with: HomePolicy}
107
+
108
+ def homes
109
+ Home.all
110
+ end
111
+ ```
112
+
113
+ The code above is equal to:
114
+
115
+ ```ruby
116
+ field :homes, [Home], null: false
117
+
118
+ def homes
119
+ authorize! "homes", to: :index?, with: HomePolicy
120
+ Home.all
121
+ end
122
+ ```
123
+
124
+ **NOTE:** we pass the field's name as the `record` to the policy rule. We assume that preauthorization rules do not depend on
125
+ the record itself and pass the field's name for debugging purposes only.
126
+
127
+ You can customize the authorization options, e.g. `preauthorize: {to: :preview?, with: CustomPolicy}`.
128
+
129
+ **NOTE:** unlike `authorize: *` you MUST specify the `with: SomePolicy` option.
130
+ The default authorization rule depends on the type of the field:
131
+
132
+ - for lists we use `index?` (configured by `ActionPolicy::GraphQL.default_preauthorize_list_rule` parameter)
133
+ - for _singleton_ fields we use `show?` (configured by `ActionPolicy::GraphQL.default_preauthorize_node_rule` parameter)
134
+
135
+ ### `authorize_field: *`
136
+
137
+ If you want to perform authorization before resolving the field value _on the base of the upper object_, you can use `authorize_field: *` option:
138
+
139
+ ```ruby
140
+ field :homes, Home, null: false, authorize_field: true
141
+
142
+ def homes
143
+ Home.all
144
+ end
145
+ ```
146
+
147
+ The code above is equal to:
148
+
149
+ ```ruby
150
+ field :homes, [Home], null: false
151
+
152
+ def homes
153
+ authorize! object, to: :homes?
154
+ Home.all
155
+ end
156
+ ```
157
+ By default we use `#{underscored_field_name}?` authorization rule.
158
+
159
+ You can customize the authorization options, e.g. `authorize_field: {to: :preview?, with: CustomPolicy}`.
160
+
99
161
  ### `expose_authorization_rules`
100
162
 
101
163
  You can add permissions/authorization exposing fields to "tell" clients which actions could be performed against the object or not (and why).
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "ruby-next"
3
4
  require "action_policy/graphql"
@@ -12,6 +12,16 @@ module ActionPolicy
12
12
  # Defaults to `:show?`
13
13
  attr_accessor :default_authorize_rule
14
14
 
15
+ # Which rule to use when no specified for preauthorization (e.g. `preauthorize: true`)
16
+ # of a list-like field.
17
+ # Defaults to `:index?`
18
+ attr_accessor :default_preauthorize_list_rule
19
+
20
+ # Which rule to use when no specified for preauthorization (e.g. `preauthorize: true`)
21
+ # of a singleton-like field.
22
+ # Defaults to `:show?`
23
+ attr_accessor :default_preauthorize_node_rule
24
+
15
25
  # Whether to raise an exeption if field is not authorized
16
26
  # or return `nil`.
17
27
  # Defaults to `true`.
@@ -20,10 +30,33 @@ module ActionPolicy
20
30
  # Which prefix to use for authorization fields
21
31
  # Defaults to `"can_"`
22
32
  attr_accessor :default_authorization_field_prefix
33
+
34
+ attr_writer :preauthorize_raise_exception
35
+
36
+ # Whether to raise an exception if preauthorization fails
37
+ # Equals to authorize_raise_exception unless explicitly set
38
+ def preauthorize_raise_exception
39
+ return authorize_raise_exception if @preauthorize_raise_exception.nil?
40
+ @preauthorize_raise_exception
41
+ end
42
+
43
+ # Whether to raise an exception if preauthorization fails
44
+ # Equals to preauthorize_raise_exception unless explicitly set
45
+ attr_writer :preauthorize_mutation_raise_exception
46
+
47
+ def preauthorize_mutation_raise_exception
48
+ return preauthorize_raise_exception if @preauthorize_mutation_raise_exception.nil?
49
+
50
+ @preauthorize_mutation_raise_exception
51
+ end
23
52
  end
24
53
 
25
54
  self.default_authorize_rule = :show?
55
+ self.default_preauthorize_list_rule = :index?
56
+ self.default_preauthorize_node_rule = :show?
26
57
  self.authorize_raise_exception = true
58
+ self.preauthorize_raise_exception = nil
59
+ self.preauthorize_mutation_raise_exception = nil
27
60
  self.default_authorization_field_prefix = "can_"
28
61
  end
29
62
  end
@@ -13,26 +13,95 @@ module ActionPolicy
13
13
  # field :comments, null: false, authorized: { type: :relation, with: MyPostPolicy }
14
14
  # end
15
15
  module AuthorizedField
16
- class AuthorizeExtension < ::GraphQL::Schema::FieldExtension
17
- def initialize(*)
18
- super
19
- options[:to] ||= ::ActionPolicy::GraphQL.default_authorize_rule
20
- options[:raise] = ::ActionPolicy::GraphQL.authorize_raise_exception unless options.key?(:raise)
16
+ class Extension < ::GraphQL::Schema::FieldExtension
17
+ def extract_option(key, &default)
18
+ value = options.fetch(key, &default)
19
+ options.delete key
20
+ value
21
+ end
22
+ end
23
+
24
+ class AuthorizeExtension < Extension
25
+ def apply
26
+ @to = extract_option(:to) { ::ActionPolicy::GraphQL.default_authorize_rule }
27
+ @raise = extract_option(:raise) do
28
+ if field.mutation
29
+ ::ActionPolicy::GraphQL.authorize_mutation_raise_exception
30
+ else
31
+ ::ActionPolicy::GraphQL.authorize_raise_exception
32
+ end
33
+ end
21
34
  end
22
35
 
23
36
  def after_resolve(value:, context:, object:, **_rest)
24
37
  return value if value.nil?
25
38
 
26
- if options[:raise]
27
- object.authorize! value, **options
39
+ if @raise
40
+ object.authorize! value, to: @to, **options
28
41
  value
29
42
  else
30
- object.allowed_to?(options[:to], value, options) ? value : nil
43
+ object.allowed_to?(@to, value, **options) ? value : nil
44
+ end
45
+ end
46
+ end
47
+
48
+ class PreauthorizeExtension < Extension
49
+ def apply
50
+ if options[:with].nil?
51
+ raise ArgumentError, "You must specify the policy for preauthorization: " \
52
+ "`field :#{field.name}, preauthorize: {with: SomePolicy}`"
53
+ end
54
+
55
+ @to = extract_option(:to) do
56
+ if field.type.list?
57
+ ::ActionPolicy::GraphQL.default_preauthorize_list_rule
58
+ else
59
+ ::ActionPolicy::GraphQL.default_preauthorize_node_rule
60
+ end
61
+ end
62
+
63
+ @raise = extract_option(:raise) do
64
+ if field.mutation
65
+ ::ActionPolicy::GraphQL.preauthorize_mutation_raise_exception
66
+ else
67
+ ::ActionPolicy::GraphQL.preauthorize_raise_exception
68
+ end
69
+ end
70
+ end
71
+
72
+ def resolve(context:, object:, arguments:, **_rest)
73
+ if @raise
74
+ object.authorize! field.name, to: @to, **options
75
+ yield object, arguments
76
+ elsif object.allowed_to?(@to, field.name, **options)
77
+ yield object, arguments
78
+ end
79
+ end
80
+ end
81
+
82
+ class AuthorizeFieldExtension < Extension
83
+ def apply
84
+ @to = extract_option(:to) { underscored_field_name }
85
+ @raise = extract_option(:raise) { ::ActionPolicy::GraphQL.authorize_raise_exception }
86
+ end
87
+
88
+ def resolve(context:, object:, arguments:, **_rest)
89
+ if @raise
90
+ object.authorize! object.object, to: @to, **options
91
+ yield object, arguments
92
+ elsif object.allowed_to?(@to, object.object, **options)
93
+ yield object, arguments
31
94
  end
32
95
  end
96
+
97
+ private
98
+
99
+ def underscored_field_name
100
+ "#{field.instance_variable_get(:@underscored_name)}?".to_sym
101
+ end
33
102
  end
34
103
 
35
- class ScopeExtension < ::GraphQL::Schema::FieldExtension
104
+ class ScopeExtension < Extension
36
105
  def after_resolve(value:, context:, object:, **_rest)
37
106
  return value if value.nil?
38
107
 
@@ -40,31 +109,41 @@ module ActionPolicy
40
109
  end
41
110
  end
42
111
 
43
- def initialize(*args, authorize: nil, authorized_scope: nil, **kwargs, &block)
112
+ def initialize(*args, preauthorize: nil, authorize: nil, authorized_scope: nil, authorize_field: nil, **kwargs, &block)
44
113
  if authorize && authorized_scope
45
114
  raise ArgumentError, "Only one of `authorize` and `authorized_scope` " \
46
- "options could be specified"
115
+ "options could be specified. You can use `preauthorize` or `authorize_field` along with scoping"
47
116
  end
48
117
 
49
- options = authorize || authorized_scope
118
+ if !!authorize == !!preauthorize ? authorize : authorize_field
119
+ raise ArgumentError, "Only one of `authorize`, `preauthorize` or `authorize_field` " \
120
+ "options could be specified."
121
+ end
50
122
 
51
- if options
52
- options = {} if options == true
123
+ extensions = (kwargs[:extensions] ||= [])
53
124
 
54
- extension_class = authorized_scope ? ScopeExtension : AuthorizeExtension
125
+ add_extension! extensions, AuthorizeExtension, authorize
126
+ add_extension! extensions, ScopeExtension, authorized_scope
127
+ add_extension! extensions, PreauthorizeExtension, preauthorize
128
+ add_extension! extensions, AuthorizeFieldExtension, authorize_field
55
129
 
56
- extension = {extension_class => options}
130
+ super(*args, **kwargs, &block)
131
+ end
57
132
 
58
- extensions = (kwargs[:extensions] ||= [])
133
+ private
59
134
 
60
- if extensions.is_a?(Hash)
61
- extensions.merge!(extension)
62
- else
63
- extensions << extension
64
- end
65
- end
135
+ def add_extension!(extensions, extension_class, options)
136
+ return unless options
66
137
 
67
- super(*args, **kwargs, &block)
138
+ options = {} if options == true
139
+
140
+ extension = {extension_class => options}
141
+
142
+ if extensions.is_a?(Hash)
143
+ extensions.merge!(extension)
144
+ else
145
+ extensions << extension
146
+ end
68
147
  end
69
148
  end
70
149
  end
@@ -6,6 +6,28 @@ require "action_policy/graphql/authorized_field"
6
6
  module ActionPolicy
7
7
  module GraphQL
8
8
  module Behaviour
9
+ require "action_policy/ext/module_namespace"
10
+ using ActionPolicy::Ext::ModuleNamespace
11
+
12
+ # When used with self.authorized?
13
+ def self.extended(base)
14
+ base.extend ActionPolicy::Behaviour
15
+ base.extend ActionPolicy::Behaviours::ThreadMemoized
16
+ base.extend ActionPolicy::Behaviours::Memoized
17
+ base.extend ActionPolicy::Behaviours::Namespaced
18
+
19
+ # Authorization context could't be defined for the class
20
+ def base.authorization_context
21
+ {}
22
+ end
23
+
24
+ # Override authorization_namespace to use the class itself
25
+ def base.authorization_namespace
26
+ return @authorization_namespace if instance_variable_defined?(:@authorization_namespace)
27
+ @authorization_namespace = namespace
28
+ end
29
+ end
30
+
9
31
  def self.included(base)
10
32
  base.include ActionPolicy::Behaviour
11
33
  base.include ActionPolicy::Behaviours::ThreadMemoized
@@ -18,6 +40,8 @@ module ActionPolicy
18
40
  base.field_class.prepend(ActionPolicy::GraphQL::AuthorizedField)
19
41
  base.include ActionPolicy::GraphQL::Fields
20
42
  end
43
+
44
+ base.extend self
21
45
  end
22
46
 
23
47
  def current_user
@@ -3,10 +3,7 @@
3
3
  require "action_policy/graphql/types/authorization_result"
4
4
 
5
5
  module ActionPolicy
6
- unless "".respond_to?(:then)
7
- require "action_policy/ext/yield_self_then"
8
- using ActionPolicy::Ext::YieldSelfThen
9
- end
6
+ using RubyNext
10
7
 
11
8
  module GraphQL
12
9
  # Add DSL to add policy rules as fields
@@ -26,26 +23,20 @@ module ActionPolicy
26
23
  base.extend ClassMethods
27
24
  end
28
25
 
29
- def allowance_to(rule, target = object, **options)
30
- policy_for(record: target, **options).then do |policy|
31
- policy.apply(authorization_rule_for(policy, rule))
32
- policy.result
33
- end
34
- end
35
-
36
26
  module ClassMethods
37
- def expose_authorization_rules(*rules, field_name: nil, prefix: ::ActionPolicy::GraphQL.default_authorization_field_prefix, **options)
27
+ def expose_authorization_rules(*rules, field_name: nil, prefix: ::ActionPolicy::GraphQL.default_authorization_field_prefix, field_options: {}, **options)
38
28
  raise ArgumentError, "Cannot specify field_name for multiple rules" if rules.size > 1 && !field_name.nil?
39
29
 
40
30
  rules.each do |rule|
41
31
  gql_field_name = field_name || "#{prefix}#{rule.to_s.delete("?")}"
42
32
 
43
33
  field gql_field_name,
44
- ActionPolicy::GraphQL::Types::AuthorizationResult,
45
- null: false
34
+ ActionPolicy::GraphQL::Types::AuthorizationResult,
35
+ null: false,
36
+ **field_options
46
37
 
47
38
  define_method(gql_field_name) do
48
- allowance_to(rule, options)
39
+ allowance_to(rule, object, **options)
49
40
  end
50
41
  end
51
42
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActionPolicy
4
4
  module GraphQL
5
- VERSION = "0.2.0"
5
+ VERSION = "0.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action_policy-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-15 00:00:00.000000000 Z
11
+ date: 2020-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: action_policy
@@ -16,14 +16,28 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: 0.3.0
19
+ version: 0.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: 0.3.0
26
+ version: 0.5.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: ruby-next
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.0
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: graphql
29
43
  requirement: !ruby/object:Gem::Requirement
@@ -58,14 +72,14 @@ dependencies:
58
72
  requirements:
59
73
  - - "~>"
60
74
  - !ruby/object:Gem::Version
61
- version: '10.0'
75
+ version: '13.0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
80
  - - "~>"
67
81
  - !ruby/object:Gem::Version
68
- version: '10.0'
82
+ version: '13.0'
69
83
  - !ruby/object:Gem::Dependency
70
84
  name: rspec
71
85
  requirement: !ruby/object:Gem::Requirement
@@ -80,48 +94,6 @@ dependencies:
80
94
  - - "~>"
81
95
  - !ruby/object:Gem::Version
82
96
  version: '3.8'
83
- - !ruby/object:Gem::Dependency
84
- name: rubocop
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - "~>"
88
- - !ruby/object:Gem::Version
89
- version: 0.67.0
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - "~>"
95
- - !ruby/object:Gem::Version
96
- version: 0.67.0
97
- - !ruby/object:Gem::Dependency
98
- name: rubocop-md
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - "~>"
102
- - !ruby/object:Gem::Version
103
- version: '0.3'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - "~>"
109
- - !ruby/object:Gem::Version
110
- version: '0.3'
111
- - !ruby/object:Gem::Dependency
112
- name: standard
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: 0.0.39
118
- type: :development
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: 0.0.39
125
97
  - !ruby/object:Gem::Dependency
126
98
  name: i18n
127
99
  requirement: !ruby/object:Gem::Requirement
@@ -143,19 +115,9 @@ executables: []
143
115
  extensions: []
144
116
  extra_rdoc_files: []
145
117
  files:
146
- - ".gitignore"
147
- - ".rubocop.yml"
148
- - ".travis.yml"
149
118
  - CHANGELOG.md
150
- - Gemfile
151
119
  - LICENSE.txt
152
120
  - README.md
153
- - Rakefile
154
- - action_policy-graphql.gemspec
155
- - bin/console
156
- - bin/setup
157
- - gemfiles/graphqlmaster.gemfile
158
- - gemfiles/jruby.gemfile
159
121
  - lib/action_policy-graphql.rb
160
122
  - lib/action_policy/graphql.rb
161
123
  - lib/action_policy/graphql/authorized_field.rb
@@ -181,14 +143,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
181
143
  requirements:
182
144
  - - ">="
183
145
  - !ruby/object:Gem::Version
184
- version: 2.4.0
146
+ version: 2.5.0
185
147
  required_rubygems_version: !ruby/object:Gem::Requirement
186
148
  requirements:
187
149
  - - ">="
188
150
  - !ruby/object:Gem::Version
189
151
  version: '0'
190
152
  requirements: []
191
- rubygems_version: 3.0.4
153
+ rubygems_version: 3.0.6
192
154
  signing_key:
193
155
  specification_version: 4
194
156
  summary: Action Policy integration for GraphQL-Ruby
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- Gemfile.local
@@ -1,54 +0,0 @@
1
- require:
2
- - standard/cop/semantic_blocks
3
- - rubocop-md
4
-
5
- inherit_gem:
6
- standard: config/base.yml
7
-
8
- AllCops:
9
- Exclude:
10
- - 'bin/*'
11
- - 'tmp/**/*'
12
- - 'Gemfile'
13
- - 'vendor/**/*'
14
- - 'gemfiles/**/*'
15
- DisplayCopNames: true
16
- TargetRubyVersion: 2.4
17
-
18
- Standard/SemanticBlocks:
19
- Enabled: false
20
-
21
- Style/FrozenStringLiteralComment:
22
- Enabled: true
23
-
24
- Style/TrailingCommaInArrayLiteral:
25
- EnforcedStyleForMultiline: no_comma
26
-
27
- Style/TrailingCommaInHashLiteral:
28
- EnforcedStyleForMultiline: no_comma
29
-
30
- Layout/AlignParameters:
31
- EnforcedStyle: with_first_parameter
32
-
33
- Lint/Void:
34
- Exclude:
35
- - '**/*.md'
36
-
37
- # See https://github.com/rubocop-hq/rubocop/issues/4222
38
- Lint/AmbiguousBlockAssociation:
39
- Exclude:
40
- - 'spec/**/*'
41
- - '**/*.md'
42
-
43
- Lint/DuplicateMethods:
44
- Exclude:
45
- - '**/*.md'
46
-
47
- Naming/FileName:
48
- Exclude:
49
- - 'lib/action_policy-graphql.rb'
50
- - '**/*.md'
51
-
52
- Layout/InitialIndentation:
53
- Exclude:
54
- - 'CHANGELOG.md'
@@ -1,33 +0,0 @@
1
- sudo: false
2
- language: ruby
3
- cache: bundler
4
- notifications:
5
- email: false
6
-
7
- before_install:
8
- - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true
9
- - gem install bundler -v '< 2'
10
-
11
- script:
12
- - bundle exec rake
13
-
14
- matrix:
15
- fast_finish: true
16
- include:
17
- - rvm: ruby-head
18
- gemfile: gemfiles/graphqlmaster.gemfile
19
- - rvm: 2.6
20
- gemfile: gemfiles/graphqlmaster.gemfile
21
- - rvm: jruby-9.2.5.0
22
- gemfile: gemfiles/jruby.gemfile
23
- - rvm: 2.6
24
- gemfile: Gemfile
25
- - rvm: 2.5
26
- gemfile: Gemfile
27
- - rvm: 2.4
28
- gemfile: Gemfile
29
- allow_failures:
30
- - rvm: ruby-head
31
- gemfile: gemfiles/graphqlmaster.gemfile
32
- - rvm: 2.6
33
- gemfile: gemfiles/graphqlmaster.gemfile
data/Gemfile DELETED
@@ -1,16 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- # Specify your gem's dependencies in action_policy-graphql.gemspec
4
- gemspec
5
-
6
- gem "pry-byebug", platform: :mri
7
-
8
- local_gemfile = File.join(__dir__, "Gemfile.local")
9
-
10
- if File.exist?(local_gemfile)
11
- # Specify custom action_policy/graphql-ruby version in Gemfile.local
12
- eval(File.read(local_gemfile)) # rubocop:disable Security/Eval
13
- else
14
- gem "action_policy", "~> 0.3.0"
15
- gem "graphql", "~> 1.9.3"
16
- end
data/Rakefile DELETED
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "rubocop/rake_task"
4
- require "rspec/core/rake_task"
5
-
6
- RuboCop::RakeTask.new
7
-
8
- RSpec::Core::RakeTask.new(:spec)
9
-
10
- task default: [:rubocop, :spec]
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- lib = File.expand_path("../lib", __FILE__)
4
- $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require "action_policy/graphql/version"
6
-
7
- Gem::Specification.new do |spec|
8
- spec.name = "action_policy-graphql"
9
- spec.version = ActionPolicy::GraphQL::VERSION
10
- spec.authors = ["Vladimir Dementyev"]
11
- spec.email = ["dementiev.vm@gmail.com"]
12
-
13
- spec.summary = "Action Policy integration for GraphQL-Ruby"
14
- spec.description = "Action Policy integration for GraphQL-Ruby"
15
- spec.homepage = "https://github.com/palkan/action_policy-graphql"
16
- spec.license = "MIT"
17
-
18
- spec.files = `git ls-files -z`.split("\x0").reject do |f|
19
- f.match(%r{^(test|spec|features)/})
20
- end
21
-
22
- spec.metadata = {
23
- "bug_tracker_uri" => "https://github.com/palkan/action_policy-graphql/issues",
24
- "changelog_uri" => "https://github.com/palkan/action_policy-graphql/blob/master/CHANGELOG.md",
25
- "documentation_uri" => "https://actionpolicy.evilmartians.io/#/graphql",
26
- "homepage_uri" => "https://github.com/palkan/action_policy-graphql",
27
- "source_code_uri" => "https://github.com/palkan/action_policy-graphql"
28
- }
29
-
30
- spec.require_paths = ["lib"]
31
-
32
- spec.required_ruby_version = ">= 2.4.0"
33
-
34
- spec.add_dependency "action_policy", ">= 0.3.0"
35
- spec.add_dependency "graphql", ">= 1.9.3"
36
-
37
- spec.add_development_dependency "bundler", ">= 1.15"
38
- spec.add_development_dependency "rake", "~> 10.0"
39
- spec.add_development_dependency "rspec", "~> 3.8"
40
- spec.add_development_dependency "rubocop", "~> 0.67.0"
41
- spec.add_development_dependency "rubocop-md", "~> 0.3"
42
- spec.add_development_dependency "standard", "~> 0.0.39"
43
- spec.add_development_dependency "i18n"
44
- end
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require "bundler/setup"
4
- require "action_policy/graphql"
5
-
6
- # You can add fixtures and/or initialization code here to make experimenting
7
- # with your gem easier. You can also use a different console, if you like.
8
-
9
- # (If you use this, don't forget to add pry to your Gemfile!)
10
- # require "pry"
11
- # Pry.start
12
-
13
- require "irb"
14
- IRB.start(__FILE__)
data/bin/setup DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
- IFS=$'\n\t'
4
- set -vx
5
-
6
- bundle install
7
-
8
- # Do any other automated setup that you need to do here
@@ -1,5 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gem "graphql", github: "rmosolgo/graphql-ruby"
4
-
5
- gemspec path: ".."
@@ -1,3 +0,0 @@
1
- source "https://rubygems.org"
2
-
3
- gemspec path: ".."