rack-cas 0.5.0 → 0.6.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
  SHA1:
3
- metadata.gz: 40ea6829e44c2f3fbb046bd53f64eba0a7b0c490
4
- data.tar.gz: 6acbdc1877f6268ef3d30d6b1c2653dd552d1250
3
+ metadata.gz: 17b2eb28b1316218061aa196765ebd91eed4165f
4
+ data.tar.gz: 6bcd8a9a58677c3244c560094e50ac7ae5e14813
5
5
  SHA512:
6
- metadata.gz: 24871eb8f49e6e7e5a1ffb74d5b3c86b8016e446d32b092f7593e91c6d6fbd5ae4022a54d620ade4167e1b7659509c36ce5d00980a1a393dc0f2a1a2d804472e
7
- data.tar.gz: da1d0360a7bc1d17fc1367950b4d6986af11a84e610c28673af18b5bf1c647cf794cf797c530ff59686daea2e1f8b408c60ea4966b63336b8d091c2ef53a46d8
6
+ metadata.gz: 0167e45bc8b7d7f770ee602d06c3fac2fc3b5567a531bea595b7d08e34a7a1d254a02095bf31297cc785f034912c5093f0a1ea7ae27523679572be7ada3a51ac
7
+ data.tar.gz: 50e6a879ecbbbcce0bb5b66a2bcdafb5281643dee09238d1106db5b47cf0de6bbf2dc8fb3b7e2b85933b92e405d8577dfdeaa637bd404e65d7ef0a6dbe0d82b0
data/README.markdown CHANGED
@@ -13,6 +13,8 @@ Current gem dependencies are [rack](http://rubygems.org/gems/rack), [addressable
13
13
  Extra attributes are a mess though. So let me know if your brand of CAS server isn't supported.
14
14
  * __Single sign out__
15
15
  One of the included session stores must be used.
16
+ * __Rake tasks to prune stale sessions__
17
+ `rack_cas:sessions:prune:active_record` and `rack_cas:sessions:prune:mongoid`
16
18
 
17
19
  Requirements
18
20
  ============
data/lib/rack/cas.rb CHANGED
@@ -39,7 +39,7 @@ class Rack::CAS
39
39
  log env, 'rack-cas: Intercepting logout request.'
40
40
 
41
41
  request.session.clear
42
- return redirect_to server.logout_url.to_s
42
+ return redirect_to server.logout_url(request.params).to_s
43
43
  end
44
44
 
45
45
  if cas_request.single_sign_out? && @session_store
@@ -71,6 +71,11 @@ class Rack::CAS
71
71
  end
72
72
 
73
73
  def store_session(request, user, ticket, extra_attrs = {})
74
+ if @config[:extra_attributes_filter]
75
+ filter = Array(@config[:extra_attributes_filter]).map(&:to_s)
76
+ extra_attrs = extra_attrs.select { |key, val| filter.include? key }
77
+ end
78
+
74
79
  request.session['cas'] = { 'user' => user, 'ticket' => ticket, 'extra_attributes' => extra_attrs }
75
80
  end
76
81
 
@@ -11,5 +11,9 @@ module RackCAS
11
11
  app.middleware.use Rack::CAS, config.rack_cas
12
12
  end
13
13
  end
14
+
15
+ rake_tasks do
16
+ load File.expand_path('../../tasks/session_prune.rake', __FILE__)
17
+ end
14
18
  end
15
- end
19
+ end
@@ -12,8 +12,11 @@ module RackCAS
12
12
  @url.dup.append_path('login').add_params(service: service_url)
13
13
  end
14
14
 
15
- def logout_url
16
- @url.dup.append_path('logout')
15
+ def logout_url(params = {})
16
+ @url.dup.tap do |url|
17
+ url.append_path('logout')
18
+ url.add_params(params) unless params.empty?
19
+ end
17
20
  end
18
21
 
19
22
  def validate_service(service_url, ticket)
@@ -9,6 +9,11 @@ module RackCAS
9
9
  affected == 1
10
10
  end
11
11
 
12
+ def self.prune(after = nil)
13
+ after ||= Time.now - 2592000 # 30 days ago
14
+ Session.where('updated_at < ?', after).delete_all
15
+ end
16
+
12
17
  private
13
18
 
14
19
  def get_session(env, sid)
@@ -16,6 +16,11 @@ module RackCAS
16
16
  affected == 1
17
17
  end
18
18
 
19
+ def self.prune(after = nil)
20
+ after ||= Time.now - 2592000 # 30 days ago
21
+ Session.where(:updated_at.lte => after).delete
22
+ end
23
+
19
24
  private
20
25
 
21
26
  def get_session(env, sid)
@@ -1,3 +1,3 @@
1
1
  module RackCAS
2
- VERSION = '0.5.0'
2
+ VERSION = '0.6.0'
3
3
  end
@@ -0,0 +1,17 @@
1
+ namespace :rack_cas do
2
+ namespace :sessions do
3
+ namespace :prune do
4
+ desc 'Delete old sessions from an Active Record session store'
5
+ task :active_record, [:after] => :environment do |t, args|
6
+ after = (Time.parse(args.after.to_s) unless args.after.nil?)
7
+ RackCAS::ActiveRecordStore.prune after
8
+ end
9
+
10
+ desc 'Delete old sessions from an Mongoid session store'
11
+ task :mongoid, [:after] => :environment do |t, args|
12
+ after = (Time.parse(args.after.to_s) unless args.after.nil?)
13
+ RackCAS::MongoidStore.prune after
14
+ end
15
+ end
16
+ end
17
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-03-13 00:00:00.000000000 Z
11
+ date: 2013-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -121,6 +121,7 @@ files:
121
121
  - lib/generators/templates/migration.rb
122
122
  - lib/rack/cas.rb
123
123
  - lib/rack/fake_cas.rb
124
+ - lib/tasks/session_prune.rake
124
125
  homepage: https://github.com/biola/rack-cas
125
126
  licenses: []
126
127
  metadata: {}