dina 0.6.1.0 → 0.6.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dina/authentication/authentication.rb +8 -24
- data/lib/dina/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40bf041e6919be1d72c4a9c737d347f137655521390502d8ea295aa88af84a4d
|
4
|
+
data.tar.gz: 9f1da8dbef7c18c16d0b639c31992ce077f9d5b93f35e3515b93990002afad2a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e711ba392d49fb80afe98c808196302c85530fd83ab67849a555dbd7890e81c978727cef898c17be1494e161f3e453af9915d118732a93733c048b329d70f20
|
7
|
+
data.tar.gz: ddf3131bf5c39099ee130907238668a1523b9e0883a5867d0fcfa4322f1e880a1b8f39fabb49de12e7811ef9929be74a6e19389b021eeb16803d4a1b39eaf7a1
|
@@ -31,6 +31,7 @@ module Dina
|
|
31
31
|
raise TokenStoreFileNotFound
|
32
32
|
end
|
33
33
|
|
34
|
+
@token = nil
|
34
35
|
@token_store_file = options[:token_store_file]
|
35
36
|
@user = options[:user]
|
36
37
|
@password = options[:password]
|
@@ -41,13 +42,16 @@ module Dina
|
|
41
42
|
Keycloak.realm = options[:realm]
|
42
43
|
|
43
44
|
if ::File.zero?(@token_store_file)
|
44
|
-
|
45
|
+
write_token(data: empty_token)
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
49
|
# Gets, sets, and renews a Bearer access token as required
|
49
50
|
# and produces a Header string
|
50
51
|
#
|
52
|
+
# WARNING: this is not likely to be threadsafe unless we do away with @token
|
53
|
+
# and load the token_store_file with every call to header
|
54
|
+
#
|
51
55
|
# @return [String] the Bearer token
|
52
56
|
def self.header
|
53
57
|
if access_token.nil? || refresh_token.nil?
|
@@ -61,29 +65,9 @@ module Dina
|
|
61
65
|
"Bearer " + access_token
|
62
66
|
end
|
63
67
|
|
64
|
-
# Flushes instance variables from memory
|
65
|
-
# but token store file content remains intact
|
66
|
-
def self.flush_variables
|
67
|
-
@token = nil
|
68
|
-
@token_store_file = nil
|
69
|
-
@user = nil
|
70
|
-
@password = nil
|
71
|
-
@server_name = nil
|
72
|
-
@client_id = nil
|
73
|
-
@endpoint_url = nil
|
74
|
-
Keycloak.auth_server_url = nil
|
75
|
-
Keycloak.realm = nil
|
76
|
-
end
|
77
|
-
|
78
|
-
# Saves default values in token store file
|
79
|
-
def self.flush_token
|
80
|
-
create_empty_token
|
81
|
-
end
|
82
|
-
|
83
68
|
# Flush instance variables and save default values in token store file
|
84
69
|
def self.flush
|
85
|
-
|
86
|
-
flush_token
|
70
|
+
write_token(data: empty_token)
|
87
71
|
end
|
88
72
|
|
89
73
|
class << self
|
@@ -148,14 +132,14 @@ module Dina
|
|
148
132
|
@token ||= JSON.parse(::File.read(@token_store_file), symbolize_names: true)
|
149
133
|
end
|
150
134
|
|
151
|
-
def
|
135
|
+
def empty_token
|
152
136
|
data = {}
|
153
137
|
data[@server_name.to_sym] = {
|
154
138
|
access_token: nil,
|
155
139
|
refresh_token: nil,
|
156
140
|
auth_expiry: nil
|
157
141
|
}
|
158
|
-
|
142
|
+
data
|
159
143
|
end
|
160
144
|
|
161
145
|
def save_token(access_token:, refresh_token:, auth_expiry:)
|
data/lib/dina/version.rb
CHANGED