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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fce6aa7545f2fe1bb7a340fd5ef64fb85ed56e50ad12b970a37cad5d0ba3bfc2
4
- data.tar.gz: 532c2e30e916fe27a13b3739efccd5adb770f12e4b6706f2fed7eec4276b80b8
3
+ metadata.gz: 40bf041e6919be1d72c4a9c737d347f137655521390502d8ea295aa88af84a4d
4
+ data.tar.gz: 9f1da8dbef7c18c16d0b639c31992ce077f9d5b93f35e3515b93990002afad2a
5
5
  SHA512:
6
- metadata.gz: 2e7ff2cd1b927195c3c17d7986e31bc60fad738dff9f7198029af2e822673b05d8ea5748db0e7aeb330fd1cd59366a5e75870556fd7cf7b74d8160b8558fa79b
7
- data.tar.gz: 95f10aa0889f8eb03b782925458398ba1ed7c066df7cb5ff94c630710170a1fd567381334207242381d6e4736cb960c4fd4edad29b047ba7328ff86aa40ae5b1
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
- create_empty_token
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
- flush_variables
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 create_empty_token
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
- write_token(data: data)
142
+ data
159
143
  end
160
144
 
161
145
  def save_token(access_token:, refresh_token:, auth_expiry:)
data/lib/dina/version.rb CHANGED
@@ -3,7 +3,7 @@ module Dina
3
3
 
4
4
  MAJOR = 0
5
5
  MINOR = 6
6
- PATCH = 1
6
+ PATCH = 2
7
7
  BUILD = 0
8
8
 
9
9
  def self.version
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dina
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1.0
4
+ version: 0.6.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David P. Shorthouse