maestrano 1.0.0.pre.RC6 → 1.0.0.pre.RC7

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
  SHA1:
3
- metadata.gz: b720f84401056435fcd026e06a127783a0dc3c07
4
- data.tar.gz: 5e6e7e0b88f4aefe47de983c8bf178e5056fa8fb
3
+ metadata.gz: 82ec4814d881186a1f8890716dc77deffdc71508
4
+ data.tar.gz: 5ee9ca302567a4fe51d41a9da379aa203279017e
5
5
  SHA512:
6
- metadata.gz: 24c500254104e9935c15a349989936e8fb3e51f6c726af7e28668f9c2e40691dd5e805a87db610bf9964f02893dce8412655745f5655c90941284d09c290fff3
7
- data.tar.gz: 8d012ab2d904f05737e72695584dddea8175957d7d924040537a138823889d2df5812fb008ea0eb676b3c0df4305f192796fa51ccb14ab52274742b601673028
6
+ metadata.gz: 853f8b39ff3255416247d6019ab51330cb0398283c9b0c63d44af929870a57498f5fd8629c5e6bd7e15a0f36266b92d8edf503a7b24d0a5be846fbfc8f8498c1
7
+ data.tar.gz: 979bc66f886591f07de3ceb00b60b0ba178b3543efe4d5bf14204c8d03a0b63f45936065cffebdf1bfd875e2fcf17aab96b551947326ed91e6e5c840a2f80bb2
@@ -2,25 +2,26 @@ module Maestrano
2
2
  module SSO
3
3
  class Session
4
4
  include Preset
5
- attr_accessor :session, :uid, :session_token, :recheck, :group_uid
6
-
5
+ attr_accessor :session, :uid, :session_token, :recheck, :group_uid, :preset
6
+
7
7
  # Load a Maestrano::SSO::Session object from a
8
8
  # hash generated by Maestrano::SSO::BaseUser#to_hash
9
9
  def self.from_user_auth_hash(session, auth)
10
10
  instance = self.new({})
11
11
  instance.session = session
12
-
12
+
13
13
  if (extra = (auth[:extra] || auth['extra'])) && (sso_session = (extra[:session] || extra['session']))
14
14
  instance.uid = (sso_session[:uid] || sso_session['uid'])
15
15
  instance.session_token = (sso_session[:token] || sso_session['token'])
16
16
  instance.group_uid = (sso_session[:group_uid] || sso_session['group_uid'])
17
+ instance.preset = self.preset
17
18
  if recheck = (sso_session[:recheck] || sso_session['recheck'])
18
19
  instance.recheck = recheck
19
20
  end
20
21
  end
21
22
  return instance
22
23
  end
23
-
24
+
24
25
  def initialize(session)
25
26
  self.session = session
26
27
  if (self.session = session)
@@ -31,42 +32,43 @@ module Maestrano
31
32
  self.session_token = decrypted_session['session']
32
33
  self.recheck = Time.iso8601(decrypted_session['session_recheck'])
33
34
  self.group_uid = decrypted_session['group_uid']
35
+ self.preset = decrypted_session['preset']
34
36
  end
35
37
  rescue
36
38
  end
37
39
  end
38
40
  end
39
-
41
+
40
42
  def remote_check_required?
41
43
  if self.uid && self.session_token && self.recheck
42
44
  return (self.recheck <= Time.now)
43
45
  end
44
46
  return true
45
47
  end
46
-
48
+
47
49
  # Check remote maestrano session and update the
48
50
  # recheck attribute if the session is still valid
49
51
  # Return true if the session is still valid and
50
52
  # false otherwise
51
53
  def perform_remote_check
52
54
  # Get remote session info
53
- url = Maestrano::SSO[self.class.preset].session_check_url(self.uid, self.session_token)
55
+ url = Maestrano::SSO[self.preset].session_check_url(self.uid, self.session_token)
54
56
  begin
55
57
  response = RestClient.get(url)
56
58
  response = JSON.parse(response)
57
59
  rescue Exception => e
58
60
  response = {}
59
61
  end
60
-
62
+
61
63
  # Process response
62
64
  if response['valid'] && response['recheck']
63
65
  self.recheck = Time.iso8601(response['recheck'])
64
66
  return true
65
67
  end
66
-
68
+
67
69
  return false
68
70
  end
69
-
71
+
70
72
  # Check whether this mno session is valid or not
71
73
  # Return true if SLO is disabled (via sso.slo_enabled config
72
74
  # param)
@@ -81,8 +83,8 @@ module Maestrano
81
83
  def valid?(opts = {})
82
84
  return true unless Maestrano[self.class.preset].param('sso.slo_enabled')
83
85
  return true if opts[:if_session] && (!self.session || (!self.session[:maestrano] && !self.session['maestrano']))
84
- return false unless self.session
85
-
86
+ return false unless self.session
87
+
86
88
  if self.remote_check_required?
87
89
  if perform_remote_check
88
90
  self.save
@@ -93,16 +95,17 @@ module Maestrano
93
95
  end
94
96
  return true
95
97
  end
96
-
98
+
97
99
  def save
98
100
  self.session[:maestrano] = Base64.encode64({
99
101
  uid: self.uid,
100
102
  session: self.session_token,
101
103
  session_recheck: self.recheck.utc.iso8601,
102
- group_uid: self.group_uid
104
+ group_uid: self.group_uid,
105
+ preset: self.preset
103
106
  }.to_json)
104
107
  end
105
-
108
+
106
109
  end
107
110
  end
108
- end
111
+ end
@@ -1,3 +1,3 @@
1
1
  module Maestrano
2
- VERSION = '1.0.0.pre.RC6'
2
+ VERSION = '1.0.0.pre.RC7'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0.pre.RC6
4
+ version: 1.0.0.pre.RC7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Lachaume