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 +4 -4
- data/lib/keycloak/client.rb +1 -1
- data/lib/keycloak/realm.rb +10 -5
- data/lib/keycloak/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9878d43fb302d62853eb782fc3383754f91868b0
|
4
|
+
data.tar.gz: 35a0684508c797d32cdce9cab24a74d11f8a3520
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: daea33df421c05d31d11e4d6fe8ee778de4a3ee1b4d6390ddd76d50e7cc93b5cb75eae70b12e2e576edc1a7def3c0ab7391169f4f41e895b11ff1c9e1dd833f8
|
7
|
+
data.tar.gz: 49940f216bba9ec05d1ddfd42664f023c5bc03bf4c3802276b0ca40dc536c8fedc2ce259cd0786c2f83752b9e5f73a345c42ca861372cb51bc4bf8a74174ba67
|
data/lib/keycloak/client.rb
CHANGED
@@ -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
|
data/lib/keycloak/realm.rb
CHANGED
@@ -37,7 +37,8 @@ module Keycloak
|
|
37
37
|
end
|
38
38
|
|
39
39
|
def parse_access_token(access_token)
|
40
|
-
|
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
|
51
|
-
return @
|
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
|
-
|
55
|
-
|
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
|
data/lib/keycloak/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2019-09-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|