maestrano 0.7.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6c1c227a0a20347f0a75185197b3baac224c968c
4
- data.tar.gz: a5b416cd223dd0cea3e04244f404d66681849a98
3
+ metadata.gz: 6dbfef2e9899e2250a41860c7bc035b608558ac2
4
+ data.tar.gz: cb1dc4e027c8e63f3b1197374e3478c200825b20
5
5
  SHA512:
6
- metadata.gz: ed5ca2ae12480f279dd8fb56a1209b5279c66a20fd00b220b1289ca5fe451c92945a63155ed9a422190a331588e17a56c62e6f4de3127e5c1d4c020b0f61d873
7
- data.tar.gz: fe08eb406c48c00bf204d03ab841330fe702eb001f18a6cd07829cdf0b50094513b5299dd00debad89ee083baa4f779071aa0e81c47eec135a7d32d37ec73eb2
6
+ metadata.gz: d44d0296bd34766d5660d6cfed0286bc3d71c7bdf516d3479d4df891a9bc2c47465091e164761d9075e2e6ace88364c04e650d0a3bdd30b457a9d66c2c856e68
7
+ data.tar.gz: 0098514aed554c30081b53233fd321a8740d6b01bf212441065cabc092d711e7c74c8f2c6e7c666c468e114920c5a921e435e772815404bc36c3178a35134aff
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- maestrano (0.6.0)
4
+ maestrano (0.8.0)
5
5
  json (~> 1.8)
6
6
  mime-types (~> 1.25)
7
7
  nokogiri (>= 1.5.0)
data/README.md CHANGED
@@ -122,6 +122,14 @@ Maestrano.configure do |config|
122
122
  #
123
123
  # config.sso.consume_path = '/maestrano/auth/saml/consume'
124
124
 
125
+ # ==> Single Logout activation
126
+ # Enable/Disable single logout. When troubleshooting authentication issues
127
+ # you might want to disable SLO temporarily.
128
+ # If set to false then Maestrano::SSO::Session#valid? - which should be
129
+ # used in a controller before filter to check user session - always return true
130
+ #
131
+ # config.sso.slo_enabled = true
132
+
125
133
  # ==> SSO User creation mode
126
134
  # !IMPORTANT
127
135
  # On Maestrano users can take several "instances" of your service. You can consider
@@ -335,7 +343,7 @@ If you want your users to benefit from single logout then you should define the
335
343
  ```ruby
336
344
  def verify_maestrano_session
337
345
  if Maestrano.param(:sso_enabled)
338
- if session && session[:mno_uid] && !Maestrano::SSO::Session.new(session).valid?
346
+ if session && session[:maestrano] && !Maestrano::SSO::Session.new(session).valid?
339
347
  redirect_to Maestrano::SSO.init_url
340
348
  end
341
349
  end
@@ -524,7 +532,16 @@ Maestrano::Account::Bill
524
532
  <td>Time</td>
525
533
  <td>-</td>
526
534
  <td>-</td>
527
- <td>When the the bill was created</td>
535
+ <td>When the bill was created</td>
536
+ <tr>
537
+
538
+ <tr>
539
+ <td><b>updated_at</b></td>
540
+ <td>readonly</td>
541
+ <td>Time</td>
542
+ <td>-</td>
543
+ <td>-</td>
544
+ <td>When the bill was last updated</td>
528
545
  <tr>
529
546
 
530
547
  <tr>
@@ -697,7 +714,16 @@ Maestrano::Account::RecurringBill
697
714
  <td>Time</td>
698
715
  <td>-</td>
699
716
  <td>-</td>
700
- <td>When the the bill was created</td>
717
+ <td>When the recurring bill was created</td>
718
+ <tr>
719
+
720
+ <tr>
721
+ <td><b>updated_at</b></td>
722
+ <td>readonly</td>
723
+ <td>Time</td>
724
+ <td>-</td>
725
+ <td>-</td>
726
+ <td>When the recurring bill was last updated</td>
701
727
  <tr>
702
728
 
703
729
  <tr>
@@ -717,6 +743,15 @@ Maestrano::Account::RecurringBill
717
743
  <td>-</td>
718
744
  <td>Status of the recurring bill. Either 'submitted', 'active', 'expired' or 'cancelled'.</td>
719
745
  <tr>
746
+
747
+ <tr>
748
+ <td><b>initial_cents</b></td>
749
+ <td>read/write</td>
750
+ <td>Integer</td>
751
+ <td><b>-</b></td>
752
+ <td>0</td>
753
+ <td>Initial non-recurring payment amount - in cents - due immediately upon creating the recurring bill</td>
754
+ <tr>
720
755
 
721
756
  </table>
722
757
 
@@ -22,15 +22,17 @@ module Maestrano
22
22
 
23
23
  def initialize(session)
24
24
  self.session = session
25
- begin
26
- if mno_session = (self.session[:maestrano] || self.session['maestrano'])
27
- decrypted_session = JSON.parse(Base64.decode64(mno_session))
28
- self.uid = decrypted_session['uid']
29
- self.session_token = decrypted_session['session']
30
- self.recheck = Time.iso8601(decrypted_session['session_recheck'])
31
- self.group_uid = decrypted_session['group_uid']
25
+ if (self.session = session)
26
+ begin
27
+ if mno_session = (self.session[:maestrano] || self.session['maestrano'])
28
+ decrypted_session = JSON.parse(Base64.decode64(mno_session))
29
+ self.uid = decrypted_session['uid']
30
+ self.session_token = decrypted_session['session']
31
+ self.recheck = Time.iso8601(decrypted_session['session_recheck'])
32
+ self.group_uid = decrypted_session['group_uid']
33
+ end
34
+ rescue
32
35
  end
33
- rescue
34
36
  end
35
37
  end
36
38
 
@@ -64,7 +66,22 @@ module Maestrano
64
66
  return false
65
67
  end
66
68
 
67
- def valid?
69
+ # Check whether this mno session is valid or not
70
+ # Return true if SLO is disabled (via sso.slo_enabled config
71
+ # param)
72
+ # Return false if no session defined
73
+ # ---
74
+ # opts:
75
+ # if_session: if true then the session will be
76
+ # considered valid if the http session is nil or does
77
+ # not have a maestrano key. Useful when the validity of
78
+ # a session should be restricted to maestrano users only
79
+ # within an application
80
+ def valid?(opts = {})
81
+ return true unless Maestrano.param('sso.slo_enabled')
82
+ return true if opts[:if_session] && (!self.session || (!self.session[:maestrano] && !self.session['maestrano']))
83
+ return false unless self.session
84
+
68
85
  if self.remote_check_required?
69
86
  if perform_remote_check
70
87
  self.save
data/lib/maestrano/sso.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  module Maestrano
2
2
  module SSO
3
+
3
4
  # Return the saml_settings based on
4
5
  # Maestrano configuration
5
6
  def self.saml_settings
@@ -71,8 +72,15 @@ module Maestrano
71
72
  Maestrano::SSO::Session.from_user_auth_hash(session,auth).save
72
73
  end
73
74
 
74
- def self.unset_session(session)
75
- session.delete(:maestrano) && session.delete('maestrano')
75
+ # Destroy the maestrano session in http session
76
+ def self.clear_session(session)
77
+ session.delete(:maestrano)
78
+ session.delete('maestrano')
79
+ end
80
+
81
+ # Metaclass definitions
82
+ class << self
83
+ alias_method :unset_session, :clear_session
76
84
  end
77
85
  end
78
86
  end
@@ -1,3 +1,3 @@
1
1
  module Maestrano
2
- VERSION = '0.7.0'
2
+ VERSION = '0.8.0'
3
3
  end
data/lib/maestrano.rb CHANGED
@@ -168,6 +168,7 @@ module Maestrano
168
168
  # SSO Config
169
169
  @sso = OpenStruct.new({
170
170
  enabled: true,
171
+ slo_enabled: true,
171
172
  creation_mode: 'virtual',
172
173
  init_path: '/maestrano/auth/saml/init',
173
174
  consume_path: '/maestrano/auth/saml/consume',
@@ -191,6 +192,7 @@ module Maestrano
191
192
  self.api.lang = 'ruby'
192
193
  self.api.lang_version = "#{RUBY_VERSION} p#{RUBY_PATCHLEVEL} (#{RUBY_RELEASE_DATE})"
193
194
  self.sso.idm ||= self.app.host
195
+ self.sso.slo_enabled &&= self.sso.enabled
194
196
  end
195
197
 
196
198
  # Transform legacy parameters into new parameter
@@ -10,6 +10,7 @@ class MaestranoTest < Test::Unit::TestCase
10
10
  'api.key' => 'someapikey',
11
11
 
12
12
  'sso.enabled' => false,
13
+ 'sso.slo_enabled' => false,
13
14
  'sso.init_path' => '/mno/sso/init',
14
15
  'sso.consume_path' => '/mno/sso/consume',
15
16
  'sso.creation_mode' => 'real',
@@ -27,6 +28,7 @@ class MaestranoTest < Test::Unit::TestCase
27
28
  config.api.key = @config['api.key']
28
29
 
29
30
  config.sso.enabled = @config['sso.enabled']
31
+ config.sso.slo_enabled = @config['sso.slo_enabled']
30
32
  config.sso.idm = @config['sso.idm']
31
33
  config.sso.init_path = @config['sso.init_path']
32
34
  config.sso.consume_path = @config['sso.consume_path']
@@ -69,6 +71,11 @@ class MaestranoTest < Test::Unit::TestCase
69
71
  assert_equal Maestrano::VERSION, Maestrano.param('api.version')
70
72
  end
71
73
 
74
+ should "force slo_enabled to false if sso is disabled" do
75
+ Maestrano.configure { |config| config.sso.slo_enabled = true; config.sso.enabled = false }
76
+ assert_false Maestrano.param('sso.slo_enabled')
77
+ end
78
+
72
79
  context "with environment params" do
73
80
  should "return the right test parameters" do
74
81
  Maestrano.configure { |config| config.environment = 'test' }
@@ -221,6 +228,7 @@ class MaestranoTest < Test::Unit::TestCase
221
228
  },
222
229
  'sso' => {
223
230
  'enabled' => @config['sso.enabled'],
231
+ 'slo_enabled' => @config['sso.slo_enabled'],
224
232
  'init_path' => @config['sso.init_path'],
225
233
  'consume_path' => @config['sso.consume_path'],
226
234
  'creation_mode' => @config['sso.creation_mode'],
@@ -101,17 +101,37 @@ module Maestrano
101
101
  context "valid?" do
102
102
  setup do
103
103
  @sso_session = Maestrano::SSO::Session.new(@session)
104
+ Maestrano.configure { |c| c.sso.slo_enabled = true }
105
+ end
106
+
107
+ should "return true if Single Logout is disabled" do
108
+ Maestrano.configure { |c| c.sso.slo_enabled = false }
109
+ @sso_session.stubs(:remote_check_required?).returns(true)
110
+ @sso_session.stubs(:perform_remote_check).returns(false)
111
+ assert @sso_session.valid?
112
+ end
113
+
114
+ should "return true if_session is enabled and session is nil" do
115
+ sso_session = Maestrano::SSO::Session.new(nil)
116
+ assert sso_session.valid?(if_session: true)
117
+ end
118
+
119
+ should "return true if_session is enabled and session is empty" do
120
+ sso_session = Maestrano::SSO::Session.new({})
121
+ assert sso_session.valid?(if_session: true)
104
122
  end
105
123
 
106
124
  should "return true if no remote_check_required?" do
107
125
  @sso_session.stubs(:remote_check_required?).returns(false)
108
126
  assert @sso_session.valid?
127
+ assert @sso_session.valid?(if_session: true)
109
128
  end
110
129
 
111
130
  should "return true if remote_check_required? and valid" do
112
131
  @sso_session.stubs(:remote_check_required?).returns(true)
113
132
  @sso_session.stubs(:perform_remote_check).returns(true)
114
133
  assert @sso_session.valid?
134
+ assert @sso_session.valid?(if_session: true)
115
135
  end
116
136
 
117
137
  should "update maestrano session with recheck timestamp if remote_check_required? and valid" do
@@ -126,7 +146,13 @@ module Maestrano
126
146
  should "return false if remote_check_required? and invalid" do
127
147
  @sso_session.stubs(:remote_check_required?).returns(true)
128
148
  @sso_session.stubs(:perform_remote_check).returns(false)
129
- assert !@sso_session.valid?
149
+ assert_false @sso_session.valid?
150
+ assert_false @sso_session.valid?(if_session: true)
151
+ end
152
+
153
+ should "return false if internal session is nil" do
154
+ sso_session = Maestrano::SSO::Session.new(nil)
155
+ assert_false @sso_session.valid?
130
156
  end
131
157
  end
132
158
 
@@ -84,6 +84,18 @@ module Maestrano
84
84
  end
85
85
 
86
86
  should "unset the session correctly" do
87
+ Maestrano::SSO.set_session(@session,@auth)
88
+ Maestrano::SSO.clear_session(@session)
89
+ assert @session[:maestrano].nil?
90
+ end
91
+
92
+ should "unset the session if key is a string" do
93
+ @session['maestrano'] = "bla"
94
+ Maestrano::SSO.clear_session(@session)
95
+ assert @session["maestrano"].nil?
96
+ end
97
+
98
+ should "alias clear_session as unset_session" do
87
99
  Maestrano::SSO.set_session(@session,@auth)
88
100
  Maestrano::SSO.unset_session(@session)
89
101
  assert @session[:maestrano].nil?
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maestrano
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arnaud Lachaume
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-09 00:00:00.000000000 Z
11
+ date: 2014-06-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client