mumukit-auth 7.5.2 → 7.6.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 +4 -4
- data/lib/mumukit/auth/grant.rb +5 -5
- data/lib/mumukit/auth/permissions.rb +14 -1
- data/lib/mumukit/auth/slug.rb +19 -7
- 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: 6e2864d6f9f4aa09030ed3d4a71f1235edb1e3d96ab88d519d1abdc57eede221
|
4
|
+
data.tar.gz: 4184f9c764bd8d54d9c93351fbf0f087df2086cd69ec7244d21a9f1031ee95f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d6a0ee484b131da39f8590d58973f98193e05f55e958326f299602e5e97c91882132ba69116f6e96ad5a7d25994c2cd4b527779f697e237a022f43197ffe8367
|
7
|
+
data.tar.gz: 0a4f659f95f3592ae4c26b286fd58c58869f071907c3ead1df0f979b5b8ea1a4b04fd6078346b3814f50d3b847eb9791dc0adc8dd01c1265a99a740e8ce0e277
|
data/lib/mumukit/auth/grant.rb
CHANGED
@@ -59,11 +59,11 @@ module Mumukit::Auth
|
|
59
59
|
|
60
60
|
class FirstPartGrant < Grant
|
61
61
|
def initialize(first)
|
62
|
-
@first = first.
|
62
|
+
@first = first.parameterize
|
63
63
|
end
|
64
64
|
|
65
65
|
def allows?(resource_slug)
|
66
|
-
resource_slug.to_mumukit_slug.match_first @first
|
66
|
+
resource_slug.to_mumukit_slug.normalize!.match_first @first
|
67
67
|
end
|
68
68
|
|
69
69
|
def to_s
|
@@ -77,16 +77,16 @@ module Mumukit::Auth
|
|
77
77
|
|
78
78
|
class SingleGrant < Grant
|
79
79
|
def initialize(slug)
|
80
|
-
@slug = slug
|
80
|
+
@slug = slug.normalize
|
81
81
|
end
|
82
82
|
|
83
83
|
def allows?(resource_slug)
|
84
|
-
resource_slug = resource_slug.to_mumukit_slug
|
84
|
+
resource_slug = resource_slug.to_mumukit_slug.normalize!
|
85
85
|
resource_slug.match_first(@slug.first) && resource_slug.match_second(@slug.second)
|
86
86
|
end
|
87
87
|
|
88
88
|
def to_s
|
89
|
-
@slug.
|
89
|
+
@slug.to_s
|
90
90
|
end
|
91
91
|
|
92
92
|
def to_mumukit_slug
|
@@ -28,8 +28,21 @@ class Mumukit::Auth::Permissions
|
|
28
28
|
self.scopes[role] ||= Mumukit::Auth::Scope.new
|
29
29
|
end
|
30
30
|
|
31
|
+
# Deprecated: use `student_granted_organizations` organizations instead
|
31
32
|
def accessible_organizations
|
32
|
-
|
33
|
+
warn "Don't use accessible_organizations, since this method is probably not doing what you would expect.\n" +
|
34
|
+
"Use student_granted_organizations if you still need its behaviour"
|
35
|
+
student_granted_organizations
|
36
|
+
end
|
37
|
+
|
38
|
+
# Answers the organizations for which the user has been explicitly granted acceses as student.
|
39
|
+
# This method does not include the organizations the user has access because of the roles hierarchy
|
40
|
+
def student_granted_organizations
|
41
|
+
granted_organizations_for :student
|
42
|
+
end
|
43
|
+
|
44
|
+
def granted_organizations_for(role)
|
45
|
+
scope_for(role)&.grants&.map { |grant| grant.to_mumukit_slug.organization }.to_set
|
33
46
|
end
|
34
47
|
|
35
48
|
def add_permission!(role, *grants)
|
data/lib/mumukit/auth/slug.rb
CHANGED
@@ -23,11 +23,11 @@ module Mumukit::Auth
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def match_first(first)
|
26
|
-
match self.first
|
26
|
+
match self.first, first
|
27
27
|
end
|
28
28
|
|
29
29
|
def match_second(second)
|
30
|
-
match self.second
|
30
|
+
match self.second, second
|
31
31
|
end
|
32
32
|
|
33
33
|
def rebase(new_organizaton)
|
@@ -35,21 +35,29 @@ module Mumukit::Auth
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def ==(o)
|
38
|
-
self.class == o.class &&
|
38
|
+
self.class == o.class && self.normalize.eql?(o.normalize)
|
39
39
|
end
|
40
40
|
|
41
|
-
|
41
|
+
def eql?(o)
|
42
|
+
self.class == o.class && to_s == o.to_s
|
43
|
+
end
|
42
44
|
|
43
45
|
def hash
|
44
|
-
|
46
|
+
to_s.hash
|
45
47
|
end
|
46
48
|
|
47
49
|
def to_s
|
48
50
|
"#{first}/#{second}"
|
49
51
|
end
|
50
52
|
|
51
|
-
def
|
52
|
-
@
|
53
|
+
def normalize!
|
54
|
+
@first = @first.parameterize
|
55
|
+
@second = @second.parameterize
|
56
|
+
self
|
57
|
+
end
|
58
|
+
|
59
|
+
def normalize
|
60
|
+
dup.normalize!
|
53
61
|
end
|
54
62
|
|
55
63
|
def inspect
|
@@ -90,6 +98,10 @@ module Mumukit::Auth
|
|
90
98
|
parse '_/_'
|
91
99
|
end
|
92
100
|
|
101
|
+
def self.normalize(first, second)
|
102
|
+
new(first, second).normalize!
|
103
|
+
end
|
104
|
+
|
93
105
|
private
|
94
106
|
|
95
107
|
def match(pattern, part)
|
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.6.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: 2019-
|
11
|
+
date: 2019-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|