mumukit-auth 7.3.0 → 7.4.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/grant.rb +10 -0
- data/lib/mumukit/auth/permissions.rb +32 -1
- data/lib/mumukit/auth/scope.rb +14 -0
- data/lib/mumukit/auth/slug.rb +10 -0
- data/lib/mumukit/auth/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: c2184d616ba0f1a7832a898adbe23ffffea1b5641b1a19bbb92b3c374228c594
|
4
|
+
data.tar.gz: 2fc2621373b9425f4c2baf9c49f8a386177658622b5c544e7790b583e6d72f05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5c72e3d088679ca3da202fba2f85ddb309a0e8a481e24610a39cf884a6d4df6a0937b1b70d6412b5cf76b9c209471f96a424739c30cd65e9ee61df5245b9b8dc
|
7
|
+
data.tar.gz: b8216c0075d4d253ee2cb04fe261582bfd8d1f8c0ac46c905342509ceb179a223de6a4f35eb3de307c8a7e8e831c7a5e4c6535207508d9abbafc30977ef6ddbc
|
data/lib/mumukit/auth/grant.rb
CHANGED
@@ -19,6 +19,16 @@ module Mumukit::Auth
|
|
19
19
|
other.class == self.class && to_s == other.to_s
|
20
20
|
end
|
21
21
|
|
22
|
+
alias_method :eql?, :==
|
23
|
+
|
24
|
+
def hash
|
25
|
+
to_s.hash
|
26
|
+
end
|
27
|
+
|
28
|
+
def inspect
|
29
|
+
"<Mumukit::Auth::Grant #{to_s}>"
|
30
|
+
end
|
31
|
+
|
22
32
|
def self.parse(pattern)
|
23
33
|
case pattern
|
24
34
|
when '*' then
|
@@ -64,7 +64,12 @@ class Mumukit::Auth::Permissions
|
|
64
64
|
def self.parse(hash)
|
65
65
|
return new if hash.blank?
|
66
66
|
|
67
|
-
new(
|
67
|
+
new(hash.map { |role, grants| [role, Mumukit::Auth::Scope.parse(grants)] }.to_h)
|
68
|
+
end
|
69
|
+
|
70
|
+
def self.reparse(something)
|
71
|
+
something ||= {}
|
72
|
+
parse(something.to_h)
|
68
73
|
end
|
69
74
|
|
70
75
|
def self.load(json)
|
@@ -84,10 +89,36 @@ class Mumukit::Auth::Permissions
|
|
84
89
|
diff.all? { |role, grant| has_permission?(role, grant) }
|
85
90
|
end
|
86
91
|
|
92
|
+
def protect_permissions_assignment!(other, previous)
|
93
|
+
raise Mumukit::Auth::UnauthorizedAccessError unless assign_to?(self.class.reparse(other), previous)
|
94
|
+
end
|
95
|
+
|
87
96
|
def as_set
|
88
97
|
Set.new scopes.flat_map { |role, scope| scope.grants.map {|grant| [role, grant]} }
|
89
98
|
end
|
90
99
|
|
100
|
+
def ==(other)
|
101
|
+
self.class == other.class && self.scopes == other.scopes
|
102
|
+
end
|
103
|
+
|
104
|
+
alias_method :eql?, :==
|
105
|
+
|
106
|
+
def hash
|
107
|
+
scopes.hash
|
108
|
+
end
|
109
|
+
|
110
|
+
def to_s
|
111
|
+
'!' + scopes.map { |role, scope| "#{role}:#{scope}" }.join(';')
|
112
|
+
end
|
113
|
+
|
114
|
+
def inspect
|
115
|
+
"<Mumukit::Auth::Permissions #{to_s}>"
|
116
|
+
end
|
117
|
+
|
118
|
+
def to_h
|
119
|
+
as_json
|
120
|
+
end
|
121
|
+
|
91
122
|
private
|
92
123
|
|
93
124
|
def has_all_permissions?(role, scope)
|
data/lib/mumukit/auth/scope.rb
CHANGED
@@ -24,10 +24,24 @@ module Mumukit::Auth
|
|
24
24
|
self.class.new grants + other.grants
|
25
25
|
end
|
26
26
|
|
27
|
+
def ==(other)
|
28
|
+
self.class == other.class && self.grants == other.grants
|
29
|
+
end
|
30
|
+
|
31
|
+
alias_method :eql?, :==
|
32
|
+
|
33
|
+
def hash
|
34
|
+
grants.hash
|
35
|
+
end
|
36
|
+
|
27
37
|
def to_s
|
28
38
|
grants.map(&:to_s).join(':')
|
29
39
|
end
|
30
40
|
|
41
|
+
def inspect
|
42
|
+
"<Mumukit::Auth::Scope #{to_s}>"
|
43
|
+
end
|
44
|
+
|
31
45
|
def present?
|
32
46
|
to_s.present?
|
33
47
|
end
|
data/lib/mumukit/auth/slug.rb
CHANGED
@@ -31,10 +31,20 @@ module Mumukit::Auth
|
|
31
31
|
self.class == o.class && to_s == o.to_s
|
32
32
|
end
|
33
33
|
|
34
|
+
alias_method :eql?, :==
|
35
|
+
|
36
|
+
def hash
|
37
|
+
to_s.hash
|
38
|
+
end
|
39
|
+
|
34
40
|
def to_s
|
35
41
|
"#{first}/#{second}"
|
36
42
|
end
|
37
43
|
|
44
|
+
def inspect
|
45
|
+
"<Mumukit::Auth::Slug #{to_s}>"
|
46
|
+
end
|
47
|
+
|
38
48
|
def to_mumukit_slug
|
39
49
|
self
|
40
50
|
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: 7.
|
4
|
+
version: 7.4.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: 2018-
|
11
|
+
date: 2018-10-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|