mumukit-auth 3.1.0 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ea91874d47681042c3ee482de3312406ca7978df
4
- data.tar.gz: 08770d172965ab3bbd1a75748d91bafea2e80afb
3
+ metadata.gz: f582e482347dc9147657752b0307c6756d81b627
4
+ data.tar.gz: 9a783d130d27f08a61fec39d6a34348c8355fb48
5
5
  SHA512:
6
- metadata.gz: 288fc8a1586feda6a2ddb47e46c3e653c51c5aec1180c4096dcb78bdc29ad1bee4e32f91ba7b432bd3544dea94e3f654b44553c8a3e10a707fcd42344e116662
7
- data.tar.gz: f34511cfbba2770ec4b7b292f3949c520791864d9417f0befca20536fce94f62aa5e456b0eb3a9563566a80ebd4cfe563af52623721e641945c28a4fbffb9d13
6
+ metadata.gz: 7154ba40df463d0110b76c96d04cc335dc421db62e310b5788d78bd9712536b4606baeac7e4c1f75040ea600f8434152f4662f314636f72851eddc578b0a5cbb
7
+ data.tar.gz: 9faa565b72369ff5213f3bd440b8c4f62726fdca9cddd423f33a513c335ad7c4e334d4be89783df03b18fe428bd160c9fd76973746ea6622c93103c2801bdaf4
@@ -39,6 +39,10 @@ module Mumukit::Auth
39
39
  def to_s
40
40
  '*'
41
41
  end
42
+
43
+ def to_mumukit_slug
44
+ Mumukit::Auth::Slug.new '*', '*'
45
+ end
42
46
  end
43
47
 
44
48
  class FirstPartGrant < Grant
@@ -53,6 +57,10 @@ module Mumukit::Auth
53
57
  def to_s
54
58
  "#{@first}/*"
55
59
  end
60
+
61
+ def to_mumukit_slug
62
+ Mumukit::Auth::Slug.new @first, '*'
63
+ end
56
64
  end
57
65
 
58
66
  class SingleGrant < Grant
@@ -68,5 +76,9 @@ module Mumukit::Auth
68
76
  def to_s
69
77
  @slug.to_s
70
78
  end
79
+
80
+ def to_mumukit_slug
81
+ @slug
82
+ end
71
83
  end
72
84
  end
@@ -25,7 +25,6 @@ class Mumukit::Auth::Permissions
25
25
  scopes[role].present?
26
26
  end
27
27
 
28
-
29
28
  def scope_for(role)
30
29
  self.scopes[role] ||= Mumukit::Auth::Scope.new
31
30
  end
@@ -43,6 +42,10 @@ class Mumukit::Auth::Permissions
43
42
  add_permission! role, new_grant
44
43
  end
45
44
 
45
+ def delegate_to?(other)
46
+ other.scopes.all? { |role, scope| has_all_permissions?(role, scope) }
47
+ end
48
+
46
49
  def as_json(options={})
47
50
  scopes.as_json(options)
48
51
  end
@@ -59,8 +62,14 @@ class Mumukit::Auth::Permissions
59
62
  end
60
63
  end
61
64
 
62
- def self.dump(user)
63
- user.to_json
65
+ def self.dump(permission)
66
+ permission.to_json
67
+ end
68
+
69
+ private
70
+
71
+ def has_all_permissions?(role, scope)
72
+ scope.grants.all? { |grant| has_permission? role, grant }
64
73
  end
65
74
 
66
75
  end
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Auth
3
- VERSION = '3.1.0'
3
+ VERSION = '3.2.0'
4
4
  end
5
5
  end
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.1.0
4
+ version: 3.2.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-21 00:00:00.000000000 Z
11
+ date: 2016-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler