action_policy-graphql 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/lib/action_policy/graphql/behaviour.rb +24 -0
- data/lib/action_policy/graphql/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a36627f17b3f0ed75370d60052cfc7f62fff25520c9bb58ba98289c1f3480903
|
4
|
+
data.tar.gz: 45f7c8b1e3a2401113f90fa3b5cf002f6efba4647a9df98209b77c4123691100
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 800c62024be3fb01378ebe900e62bd5fbc9343f27857dfa4c20125dd007ce6260e037599880df2e3d97cdab136466c272f6d3756f994595d46b4dbd3514ed330
|
7
|
+
data.tar.gz: 37287ca3abcf008b787f8b9e504db6f4f396f22e4aab5c628524b8d2f543f99e043730ff2ec7455dbce106c7820578040576275e85f546d80f2ea0671d1fd642
|
data/CHANGELOG.md
CHANGED
@@ -2,6 +2,10 @@
|
|
2
2
|
|
3
3
|
## master (unreleased)
|
4
4
|
|
5
|
+
## 0.3.1 (2019-10-23)
|
6
|
+
|
7
|
+
- Add support for using Action Policy methods in `self.authorized?`. ([@palkan][])
|
8
|
+
|
5
9
|
## 0.3.0 (2019-10-21)
|
6
10
|
|
7
11
|
- Add `preauthorize: *` option to perform authorization prior to resolving fields. ([@palkan][])
|
@@ -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
|
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.3.
|
4
|
+
version: 0.3.1
|
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-10-
|
11
|
+
date: 2019-10-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: action_policy
|