keycloak-ruby-client 0.0.11 → 0.0.12

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: 13f981a3377badd726b4a4869b71450891a14948
4
- data.tar.gz: 5d53ca4983508dc7f18961fd2fc453d8cf9ed32d
3
+ metadata.gz: 9878d43fb302d62853eb782fc3383754f91868b0
4
+ data.tar.gz: 35a0684508c797d32cdce9cab24a74d11f8a3520
5
5
  SHA512:
6
- metadata.gz: 9056dde4936b9e36cd54b0a0c4c9ebe268020b6448f5fa5936740164cb3c278ec4717c64935c5324b80dcc77858970676357ecf17ce3b31a1a1ab7a66bbc8c2a
7
- data.tar.gz: 5ff7a88bed82b600f215b323d06f7db2bf91e6bd61e7585192e7f4d38a3a83ae65f0a1b3a14843be56c8f5a09148fe302f2e55b6eaca9aad7ed78df899d6dc53
6
+ metadata.gz: daea33df421c05d31d11e4d6fe8ee778de4a3ee1b4d6390ddd76d50e7cc93b5cb75eae70b12e2e576edc1a7def3c0ab7391169f4f41e895b11ff1c9e1dd833f8
7
+ data.tar.gz: 49940f216bba9ec05d1ddfd42664f023c5bc03bf4c3802276b0ca40dc536c8fedc2ce259cd0786c2f83752b9e5f73a345c42ca861372cb51bc4bf8a74174ba67
@@ -33,6 +33,7 @@ module Keycloak
33
33
  @authenticate_grant_type = grant_type
34
34
  end
35
35
 
36
+ now = DateTime.now
36
37
  url = "#{@auth_server_url}/realms/#{realm}/protocol/openid-connect/token"
37
38
  res = JSON.parse post(url, {
38
39
  username: username,
@@ -42,7 +43,6 @@ module Keycloak
42
43
  }, try_refresh_token: false).body
43
44
  @access_token = res["access_token"]
44
45
  @refresh_token = res["refresh_token"]
45
- now = DateTime.now
46
46
  @refresh_expires_in = now + res["refresh_expires_in"].seconds
47
47
  @expires_in = now + res["expires_in"].seconds
48
48
  true
@@ -37,7 +37,8 @@ module Keycloak
37
37
  end
38
38
 
39
39
  def parse_access_token(access_token)
40
- decoded_token = JWT.decode access_token, public_key, false, { :algorithm => 'RS256' }
40
+ alg = JWT.decode(access_token, nil, false)[1]["alg"]
41
+ decoded_token = JWT.decode access_token, public_keys[alg], true, algorithm: alg
41
42
  AccessToken.new self, access_token, decoded_token
42
43
  end
43
44
 
@@ -47,12 +48,16 @@ module Keycloak
47
48
 
48
49
  private
49
50
 
50
- def public_key
51
- return @public_key if @public_key
51
+ def public_keys
52
+ return @public_keys if @public_keys
52
53
 
53
54
  keys = JSON.parse(RestClient.get("#{auth_server_url}/realms/#{realm}/protocol/openid-connect/certs").body)['keys']
54
- jwk = JSON::JWK.new(keys[0])
55
- @public_key = jwk.to_key
55
+ @public_keys = {}
56
+ keys.each do |key|
57
+ jwk = JSON::JWK.new(key)
58
+ @public_keys[key["alg"]] = jwk.to_key
59
+ end
60
+ @public_keys
56
61
  end
57
62
  end
58
63
  end
@@ -1,3 +1,3 @@
1
1
  module Keycloak
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.12"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: keycloak-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Fuxin Hao
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-30 00:00:00.000000000 Z
11
+ date: 2019-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails