mumukit-auth 3.7.0 → 4.0.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: f7112014b6bdb6ee999233edd32147258c8594a7
4
- data.tar.gz: 4f02d55e1e0eecafdcf07cc2ac98a18b3054914b
3
+ metadata.gz: ff4b114d44e8e0f561db33664147f3284c7a174c
4
+ data.tar.gz: 1e3eafff3f4e11a8282daf91c88e33a7ae66688f
5
5
  SHA512:
6
- metadata.gz: ade2a74bb06ef33cc42bf17cf343d22eef2ce9d8719630c5abdaeeef696cee14cd12786c86a3004378433b59d4d5b6557bf8a6b60debe49a836b08a53f90424f
7
- data.tar.gz: 985a6ffddf29cd2599d924df36d9a1598d2b49bbc49030f0f56de3d39996ebc8a6fc8d3b2591735aacbe2cbd51bc02d507caa6c480da53a3610b33773379e847
6
+ metadata.gz: ebdd2c656a4d7d7854909bc34cc6042846a64fbf7394062c3c54b6d9f6342707435844cf945089a2475849353e671449761821f244de8a80e577b19ed92230d1
7
+ data.tar.gz: 063b4d5d45e68f002efd0fe2eaae4c6d753c61268c35332ea845eba0d439230668d1e8f44c33be75186a4d713e0838f445d328b70a1e1b782d8ec7d0b47e19f8
@@ -22,6 +22,7 @@ module Mumukit::Auth
22
22
  end
23
23
 
24
24
  def clean_env!
25
+ close
25
26
  FileUtils.rm ["#{Mumukit::Auth.config.daybreak_name}.db"], force: true
26
27
  end
27
28
  end
@@ -24,34 +24,34 @@ module Mumukit::Auth
24
24
  permissions.protect! scope, resource_slug
25
25
  end
26
26
 
27
- def verify_client!
28
- raise Mumukit::Auth::InvalidTokenError.new('aud mismatch') if Mumukit::Auth.config.client_id != jwt['aud']
27
+ def verify_client!(client = :auth0)
28
+ raise Mumukit::Auth::InvalidTokenError.new('aud mismatch') if Mumukit::Auth.config.client_ids[client] != jwt['aud']
29
29
  end
30
30
 
31
- def encode
32
- JWT.encode(jwt, self.class.decoded_secret)
31
+ def encode(client = :auth0)
32
+ JWT.encode(jwt, self.class.decoded_secret(client))
33
33
  end
34
34
 
35
35
  def self.from_rack_env(env)
36
36
  new(env.dig('omniauth.auth', 'extra', 'raw_info') || {})
37
37
  end
38
38
 
39
- def self.encode_dummy_auth_header(uid, metadata)
40
- 'dummy token ' + encode(uid, metadata)
39
+ def self.encode_dummy_auth_header(uid, metadata, client = :auth0)
40
+ 'dummy token ' + encode(uid, metadata, client)
41
41
  end
42
42
 
43
- def self.encode(uid, metadata)
44
- new(aud: Mumukit::Auth.config.client_id, metadata: metadata, uid: uid).encode
43
+ def self.encode(uid, metadata, client = :auth0)
44
+ new(aud: Mumukit::Auth.config.client_ids[client], metadata: metadata, uid: uid).encode client
45
45
  end
46
46
 
47
- def self.decode(encoded)
48
- Token.new JWT.decode(encoded, decoded_secret)[0]
47
+ def self.decode(encoded, client = :auth0)
48
+ Token.new JWT.decode(encoded, decoded_secret(client))[0]
49
49
  rescue JWT::DecodeError => e
50
50
  raise Mumukit::Auth::InvalidTokenError.new(e)
51
51
  end
52
52
 
53
- def self.decode_header(header)
54
- decode extract_from_header header
53
+ def self.decode_header(header, client = :auth0)
54
+ decode extract_from_header(header), client
55
55
  end
56
56
 
57
57
  def self.extract_from_header(header)
@@ -59,8 +59,9 @@ module Mumukit::Auth
59
59
  header.split(' ').last
60
60
  end
61
61
 
62
- def self.decoded_secret
63
- JWT.base64url_decode(Mumukit::Auth.config.client_secret)
62
+ def self.decoded_secret(client = :auth0)
63
+ client_secret = Mumukit::Auth.config.client_secrets[client]
64
+ JWT.base64url_decode(client_secret)
64
65
  end
65
66
  end
66
67
  end
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Auth
3
- VERSION = '3.7.0'
3
+ VERSION = '4.0.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.7.0
4
+ version: 4.0.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: 2017-01-05 00:00:00.000000000 Z
11
+ date: 2017-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler