pastore 0.0.2 → 0.0.3
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/Gemfile.lock +1 -1
- data/lib/pastore/guards/settings.rb +15 -4
- data/lib/pastore/guards.rb +1 -1
- data/lib/pastore/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: 18748116f3fc80df20d80cb5a47476750ca7e25fe14d249ce90c80e29939f14a
|
|
4
|
+
data.tar.gz: f96b3c8969cc3b65e9ec3992bb1b20dba39e3fc271b11523c767b2c4c0e1ba12
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 5e5a985b839f0223e0a52b5e1dc61423fa70a407460d64f02d42a7b1d53a9609d0568acdc918804bb994cb1f93bb763fcbedb415be496a5ef57a7006274666c7
|
|
7
|
+
data.tar.gz: c2c2d1f2509e854c96b4ffb97369f3f31a6b60363b23db317a1d69b48c0d8a92d2f464af60a9e4ad220aa11ab25ab6d032b358876704842ddc27d9dd8042aac5
|
data/Gemfile.lock
CHANGED
|
@@ -4,10 +4,13 @@ module Pastore
|
|
|
4
4
|
module Guards
|
|
5
5
|
# Implements a structure where to store the settings for the guards.
|
|
6
6
|
class Settings # rubocop:disable Metrics/ClassLength
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
attr_writer :role_detector, :forbidden_cbk
|
|
8
9
|
attr_reader :strategy
|
|
9
10
|
|
|
10
|
-
def initialize
|
|
11
|
+
def initialize(superklass)
|
|
12
|
+
@super_guards = superklass.pastore_guards if superklass.respond_to?(:pastore_guards)
|
|
13
|
+
@superclass = superklass
|
|
11
14
|
reset!
|
|
12
15
|
end
|
|
13
16
|
|
|
@@ -21,6 +24,14 @@ module Pastore
|
|
|
21
24
|
@forced_guards = []
|
|
22
25
|
end
|
|
23
26
|
|
|
27
|
+
def role_detector
|
|
28
|
+
@role_detector || @super_guards&.role_detector
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def forbidden_cbk
|
|
32
|
+
@forbidden_cbk || @super_guards&.forbidden_cbk
|
|
33
|
+
end
|
|
34
|
+
|
|
24
35
|
def use_allow_strategy!
|
|
25
36
|
@strategy = :allow
|
|
26
37
|
end
|
|
@@ -101,9 +112,9 @@ module Pastore
|
|
|
101
112
|
|
|
102
113
|
# Returns the current role for the controller.
|
|
103
114
|
def current_role(controller)
|
|
104
|
-
return nil if
|
|
115
|
+
return nil if role_detector.blank?
|
|
105
116
|
|
|
106
|
-
controller.instance_exec(
|
|
117
|
+
controller.instance_exec(&role_detector)&.to_s
|
|
107
118
|
end
|
|
108
119
|
|
|
109
120
|
def access_granted?(controller, action_name) # rubocop:disable Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
data/lib/pastore/guards.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Pastore
|
|
|
28
28
|
attr_accessor :_pastore_guards
|
|
29
29
|
|
|
30
30
|
def pastore_guards
|
|
31
|
-
self._pastore_guards ||= Pastore::Guards::Settings.new
|
|
31
|
+
self._pastore_guards ||= Pastore::Guards::Settings.new(superclass)
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
# Sets the logic to use for current role detection.
|
data/lib/pastore/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pastore
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Groza Sergiu
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2023-02-
|
|
11
|
+
date: 2023-02-02 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rails
|