mumukit-auth 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/mumukit/auth/permissions.rb +6 -2
- data/lib/mumukit/auth/scope.rb +22 -2
- data/lib/mumukit/auth/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fbc5aece9f1ceef11e2f32c4e1bb84a4644031b
|
4
|
+
data.tar.gz: 588bd33d6ba3f2d5e01e03242a461b67a369277e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56728c7d40f73f4f6a8a7c35189b355b72842d44fc2ab08ccce57b4bae7eeb5e180731ccb89e3bab3529a49734c723be4b6856d931a9c2f15917385e00df7d72
|
7
|
+
data.tar.gz: d6caaa9740b5ed65217ad769ffcfc6e42159454b5facfffd0250a63587f7236ddccd7d55053c7ec0393e478e19255f55873697f101eea1109cd119756fefd771
|
@@ -30,11 +30,15 @@ class Mumukit::Auth::Permissions
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def add_permission!(role, *grants)
|
33
|
-
scope_for(role)
|
33
|
+
scope_for(role).add_grant! *grants
|
34
|
+
end
|
35
|
+
|
36
|
+
def merge(other)
|
37
|
+
self.class.new(scopes.merge(other.scopes) { |_key, left, right| left.merge right})
|
34
38
|
end
|
35
39
|
|
36
40
|
def remove_permission!(role, grant)
|
37
|
-
scope_for(role)
|
41
|
+
scope_for(role).remove_grant!(grant)
|
38
42
|
end
|
39
43
|
|
40
44
|
def update_permission!(role, old_grant, new_grant)
|
data/lib/mumukit/auth/scope.rb
CHANGED
@@ -3,7 +3,8 @@ module Mumukit::Auth
|
|
3
3
|
attr_accessor :grants
|
4
4
|
|
5
5
|
def initialize(grants=[])
|
6
|
-
@grants =
|
6
|
+
@grants = []
|
7
|
+
add_grant! *grants
|
7
8
|
end
|
8
9
|
|
9
10
|
def protect!(resource_slug)
|
@@ -15,7 +16,7 @@ module Mumukit::Auth
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def add_grant!(*grants)
|
18
|
-
|
19
|
+
grants.each { |grant| push_and_compact! grant }
|
19
20
|
end
|
20
21
|
|
21
22
|
def remove_grant!(grant)
|
@@ -23,6 +24,10 @@ module Mumukit::Auth
|
|
23
24
|
self.grants.delete(grant)
|
24
25
|
end
|
25
26
|
|
27
|
+
def merge(other)
|
28
|
+
self.class.new grants + other.grants
|
29
|
+
end
|
30
|
+
|
26
31
|
def to_s
|
27
32
|
grants.map(&:to_s).join(':')
|
28
33
|
end
|
@@ -44,5 +49,20 @@ module Mumukit::Auth
|
|
44
49
|
def any_grant?(&block)
|
45
50
|
@grants.any?(&block)
|
46
51
|
end
|
52
|
+
|
53
|
+
def push_and_compact!(grant)
|
54
|
+
grant = grant.to_mumukit_grant
|
55
|
+
return if has_broader_grant? grant
|
56
|
+
remove_narrower_grants! grant
|
57
|
+
grants << grant
|
58
|
+
end
|
59
|
+
|
60
|
+
def remove_narrower_grants!(grant)
|
61
|
+
grants.reject! { |it| grant.allows? it }
|
62
|
+
end
|
63
|
+
|
64
|
+
def has_broader_grant?(grant)
|
65
|
+
grants.any? { |it| it.allows? grant }
|
66
|
+
end
|
47
67
|
end
|
48
68
|
end
|
data/lib/mumukit/auth/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit-auth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Franco Leonardo Bulgarelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|