mumukit-auth 2.2.0 → 2.2.1

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: 822a6899489c66e29fcf58843040f7db681eb322
4
- data.tar.gz: 2b8d6099424c7d62797275bf01f425b888907901
3
+ metadata.gz: bed8166905e564a1dba63d8b2d5360d9a53d9885
4
+ data.tar.gz: 67891d8319dec63be952ba8d6460ab291de6f272
5
5
  SHA512:
6
- metadata.gz: 089dfa0aa8114c662c792b1e376f365a46a8a9a00c141c98db30ea76732335dffb05926f0e0b6a347fd4b9926577aa902285c5b7c763e247250e1b0a69e5a5fc
7
- data.tar.gz: 3b7312806588e1e707099c6f090ef4e02aa3b520b91547e84b4a2bdd06f4904219be5c4251956ab6f649980e4fc5c4f2899785b5e5e9e2e95c40e364c98ff85c
6
+ metadata.gz: 43be1045c6041c315bf2dba475a93df6188ee5ede68cbf8e3bea9a21d204295a1940f1a4911dbd6042e97627d798d0822da5f0083f4f457088d4d22f690b4522
7
+ data.tar.gz: ce9947379341de7fc345cf60d5c1acedad17d77282288a96ac1df2b53e15d8c0d198dea29645a24a1254f235820682c52fa0918278d8860858629dfd3f803c2b
@@ -13,6 +13,10 @@ class Mumukit::Auth::Permissions
13
13
  !!scope_for(role)&.allows?(resource_slug)
14
14
  end
15
15
 
16
+ def protect!(scope, slug)
17
+ scope_for(scope)&.protect!(slug)
18
+ end
19
+
16
20
  def has_role?(role)
17
21
  scopes[role].present?
18
22
  end
@@ -16,6 +16,10 @@ module Mumukit::Auth
16
16
  raise Mumukit::Auth::InvalidTokenError.new('aud mismatch') if Mumukit::Auth.config.client_id != jwt['aud']
17
17
  end
18
18
 
19
+ def encode
20
+ JWT.encode(jwt, self.class.decoded_secret)
21
+ end
22
+
19
23
  def self.from_rack_env(env)
20
24
  new(env.dig('omniauth.auth', 'extra', 'raw_info') || {})
21
25
  end
@@ -25,7 +29,7 @@ module Mumukit::Auth
25
29
  end
26
30
 
27
31
  def self.encode(metadata)
28
- JWT.encode({aud: Mumukit::Auth.config.client_id, metadata: metadata}, decoded_secret)
32
+ new(aud: Mumukit::Auth.config.client_id, metadata: metadata).encode
29
33
  end
30
34
 
31
35
  def self.decode(encoded)
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Auth
3
- VERSION = '2.2.0'
3
+ VERSION = '2.2.1'
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: 2.2.0
4
+ version: 2.2.1
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-16 00:00:00.000000000 Z
11
+ date: 2016-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler