dina 0.6.0.0 → 0.6.1.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 +25 -13
- data/lib/dina/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fce6aa7545f2fe1bb7a340fd5ef64fb85ed56e50ad12b970a37cad5d0ba3bfc2
|
4
|
+
data.tar.gz: 532c2e30e916fe27a13b3739efccd5adb770f12e4b6706f2fed7eec4276b80b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2e7ff2cd1b927195c3c17d7986e31bc60fad738dff9f7198029af2e822673b05d8ea5748db0e7aeb330fd1cd59366a5e75870556fd7cf7b74d8160b8558fa79b
|
7
|
+
data.tar.gz: 95f10aa0889f8eb03b782925458398ba1ed7c066df7cb5ff94c630710170a1fd567381334207242381d6e4736cb960c4fd4edad29b047ba7328ff86aa40ae5b1
|
@@ -63,7 +63,8 @@ module Dina
|
|
63
63
|
|
64
64
|
# Flushes instance variables from memory
|
65
65
|
# but token store file content remains intact
|
66
|
-
def self.
|
66
|
+
def self.flush_variables
|
67
|
+
@token = nil
|
67
68
|
@token_store_file = nil
|
68
69
|
@user = nil
|
69
70
|
@password = nil
|
@@ -74,11 +75,17 @@ module Dina
|
|
74
75
|
Keycloak.realm = nil
|
75
76
|
end
|
76
77
|
|
77
|
-
#
|
78
|
+
# Saves default values in token store file
|
78
79
|
def self.flush_token
|
79
80
|
create_empty_token
|
80
81
|
end
|
81
82
|
|
83
|
+
# Flush instance variables and save default values in token store file
|
84
|
+
def self.flush
|
85
|
+
flush_variables
|
86
|
+
flush_token
|
87
|
+
end
|
88
|
+
|
82
89
|
class << self
|
83
90
|
attr_accessor :endpoint_url
|
84
91
|
|
@@ -86,7 +93,7 @@ module Dina
|
|
86
93
|
|
87
94
|
def access_token
|
88
95
|
begin
|
89
|
-
|
96
|
+
token[@server_name.to_sym][:access_token]
|
90
97
|
rescue
|
91
98
|
raise TokenStoreContentInvalid
|
92
99
|
end
|
@@ -94,7 +101,7 @@ module Dina
|
|
94
101
|
|
95
102
|
def refresh_token
|
96
103
|
begin
|
97
|
-
|
104
|
+
token[@server_name.to_sym][:refresh_token]
|
98
105
|
rescue
|
99
106
|
raise TokenStoreContentInvalid
|
100
107
|
end
|
@@ -102,7 +109,7 @@ module Dina
|
|
102
109
|
|
103
110
|
def auth_expiry
|
104
111
|
begin
|
105
|
-
|
112
|
+
token[@server_name.to_sym][:auth_expiry]
|
106
113
|
rescue
|
107
114
|
raise TokenStoreContentInvalid
|
108
115
|
end
|
@@ -137,28 +144,33 @@ module Dina
|
|
137
144
|
end
|
138
145
|
end
|
139
146
|
|
140
|
-
def
|
141
|
-
JSON.parse(::File.read(@token_store_file), symbolize_names: true)
|
147
|
+
def token
|
148
|
+
@token ||= JSON.parse(::File.read(@token_store_file), symbolize_names: true)
|
142
149
|
end
|
143
150
|
|
144
151
|
def create_empty_token
|
145
|
-
|
146
|
-
|
152
|
+
data = {}
|
153
|
+
data[@server_name.to_sym] = {
|
147
154
|
access_token: nil,
|
148
155
|
refresh_token: nil,
|
149
156
|
auth_expiry: nil
|
150
157
|
}
|
151
|
-
|
158
|
+
write_token(data: data)
|
152
159
|
end
|
153
160
|
|
154
161
|
def save_token(access_token:, refresh_token:, auth_expiry:)
|
155
|
-
|
156
|
-
|
162
|
+
data = JSON.parse(::File.read(@token_store_file), symbolize_names: true) rescue {}
|
163
|
+
data[@server_name.to_sym] = {
|
157
164
|
access_token: access_token,
|
158
165
|
refresh_token: refresh_token,
|
159
166
|
auth_expiry: auth_expiry
|
160
167
|
}
|
161
|
-
|
168
|
+
write_token(data: data)
|
169
|
+
end
|
170
|
+
|
171
|
+
def write_token(data:)
|
172
|
+
::File.write(@token_store_file, JSON.dump(data))
|
173
|
+
@token = data
|
162
174
|
end
|
163
175
|
|
164
176
|
end
|
data/lib/dina/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dina
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David P. Shorthouse
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-12-
|
11
|
+
date: 2022-12-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json_api_client
|