mn_utils_gem 1.15.0 → 1.15.1

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: 6e7292a8e70611c5bf7971d203841260cc3b2d7a84f87f249a82c0caac84175a
4
- data.tar.gz: f6de5171379b867c8f1d002e61a1eb4d4c705437dcdd179c8d98c5e8b9485f82
3
+ metadata.gz: ce04246925c9e620cad30e8f2899be5f9f833a3d897ddd8f8bb41574c9412ced
4
+ data.tar.gz: f423d16543105226239e6824cb258b03f9f32fecac6764051fb02914d22e9da0
5
5
  SHA512:
6
- metadata.gz: e04c99269319b133fdd37462a02933123097b111f8543ad0d9a2184d209512cc8382e80f93b2e879501816fbd37e366751817be73e13803954a20b62b83122a4
7
- data.tar.gz: bb1619401461f39a203bb075a481117dc137fe98c5430a72c8a0d19aa309715c190680f8fd381d9086532da4680af4e7df5803fb381061e7954c9edc20aebfe8
6
+ metadata.gz: f99670585184657c736a94abcfe2d67d42f03e2c36c71af7acef0ab390b7dd073e45efa6e3199dcdfae2f743ca17797576e93aebbcd690f62492f0a4196e3aa0
7
+ data.tar.gz: e68a6200d6d7568571966a4e0cb7bab9caca041ba1eb0245eb85951a864761412d618795d35da9c5f3fa4838dac1e7c45168764839bef74f862659571d150448
data/lib/mn_utils_gem.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "mn_utils_gem/version"
2
+ require "mn_utils_gem/string_to_bool"
2
3
  require "mn_utils_gem/site_action"
3
4
  require "mn_utils_gem/gui"
4
5
  require "mn_utils_gem/transactional_email"
@@ -16,8 +16,6 @@ module MnUtilsAuth
16
16
  def get_sso_user_id(cookies)
17
17
  raise ArgumentError, "ENV['MN_REDIS_URL'] is required" \
18
18
  unless ENV.key? 'MN_REDIS_URL'
19
- raise ArgumentError, "ENV['COOKIE_DOMAIN'] is required" \
20
- unless ENV.key? 'COOKIE_DOMAIN'
21
19
  parsed = get_sso cookies
22
20
  return nil if parsed.nil?
23
21
  parsed[:user_id]
@@ -29,8 +27,6 @@ module MnUtilsAuth
29
27
  def get_sso(cookies)
30
28
  raise ArgumentError, "ENV['MN_REDIS_URL'] is required" \
31
29
  unless ENV.key? 'MN_REDIS_URL'
32
- raise ArgumentError, "ENV['COOKIE_DOMAIN'] is required" \
33
- unless ENV.key? 'COOKIE_DOMAIN'
34
30
  return RequestStore.store[:sso] if RequestStore.store[:sso]
35
31
  return nil if cookies.nil? || cookies[SSO_COOKIE_NAME].nil? || redis_server.nil?
36
32
  json = redis_server.get(cookies[SSO_COOKIE_NAME])
@@ -47,29 +43,19 @@ module MnUtilsAuth
47
43
  def set_sso(cookies, user_id, persistent, other_attributes = {})
48
44
  raise ArgumentError, "ENV['MN_REDIS_URL'] is required" \
49
45
  unless ENV.key? 'MN_REDIS_URL'
50
- raise ArgumentError, "ENV['COOKIE_DOMAIN'] is required" \
51
- unless ENV.key? 'COOKIE_DOMAIN'
52
46
  return if cookies.nil? || user_id.blank? || RequestStore.store[:sso] || redis_server.nil?
53
47
  value = other_attributes.reverse_merge({ user_id: user_id })
54
48
  redis_ttl = (persistent) ? 1.year.to_i : 1.day.to_i
55
- if cookies[SSO_COOKIE_NAME].nil?
49
+ if cookies[SSO_COOKIE_NAME].nil? || !redis_server.get(cookies[SSO_COOKIE_NAME])
56
50
  cookie = set_sso_cookie cookies, persistent
57
51
  redis_server.set(cookie, JSON[value], ex: redis_ttl)
58
52
  RequestStore.store[:sso] = value
59
- else
60
- if !redis_server.get(cookies[SSO_COOKIE_NAME])
61
- cookie = set_sso_cookie cookies, persistent
62
- redis_server.set(cookie, JSON[value], ex: redis_ttl)
63
- RequestStore.store[:sso] = value
64
- end
65
53
  end
66
54
  end
67
55
 
68
56
  def delete_sso(cookies)
69
57
  raise ArgumentError, "ENV['MN_REDIS_URL'] is required" \
70
58
  unless ENV.key? 'MN_REDIS_URL'
71
- raise ArgumentError, "ENV['COOKIE_DOMAIN'] is required" \
72
- unless ENV.key? 'COOKIE_DOMAIN'
73
59
  if cookies[SSO_COOKIE_NAME]
74
60
  redis_server.del(cookies[SSO_COOKIE_NAME])
75
61
  cookies.delete SSO_COOKIE_NAME
@@ -85,7 +71,6 @@ module MnUtilsAuth
85
71
  expiry = persistent ? 1.year.from_now : 1.day.from_now
86
72
  cookies[SSO_COOKIE_NAME] = {
87
73
  value: cookie_value,
88
- domain: ENV['COOKIE_DOMAIN'],
89
74
  expires: expiry,
90
75
  secure: true,
91
76
  httponly: true
@@ -96,7 +81,7 @@ module MnUtilsAuth
96
81
  def redis_server
97
82
  @redis_server ||= Redis.new(
98
83
  url: ENV['MN_REDIS_URL'],
99
- ssl: SharedService.string_to_bool(ENV['MN_REDIS_SSL']),
84
+ ssl: ENV['MN_REDIS_SSL'].to_bool,
100
85
  semian: {
101
86
  name: 'user-service',
102
87
  tickets: 4,
@@ -1,3 +1,3 @@
1
1
  module MnUtilsGem
2
- VERSION = "1.15.0"
2
+ VERSION = "1.15.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mn_utils_gem
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.15.0
4
+ version: 1.15.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Shamim Mirzai
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-07 00:00:00.000000000 Z
11
+ date: 2019-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: gelf