cassiopeia 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -7,6 +7,7 @@
7
7
  - Yet another custom CAS client/server implementation. This plugin allows you to perform single-server authorization between two different rails applications.
8
8
 
9
9
  = Changelog:
10
+ - 0.0.9: The bug with multiple concurrent requests processing fixed.
10
11
  - 0.0.8: Full request saving support via rack middleware.
11
12
  - 0.0.7: Some code for redirection added. Added webpath prefix support.
12
13
  - 0.0.6: Tiny refactoring.
data/Rakefile CHANGED
@@ -10,7 +10,7 @@ PKG_FILES = FileList[ '[a-zA-Z]*', 'lib/**/*' ]
10
10
 
11
11
  spec = Gem::Specification.new do |s|
12
12
  s.name = "cassiopeia"
13
- s.version = "0.0.8"
13
+ s.version = "0.0.9"
14
14
  s.author = "smecsia"
15
15
  s.email = "smecsia@gmail.com"
16
16
  #s.homepage = ""
@@ -16,12 +16,14 @@ module Cassiopeia
16
16
  :service_id => nil,
17
17
  :current_user_key => "current_user",
18
18
  :format => "js",
19
- :rack_session_store => "cas_rack_session",
20
- :rack_session_key => "rack.session",
21
19
  :rack_request_uri_key => "REQUEST_URI",
22
20
  :rack_query_string_key => "QUERY_STRING",
23
21
  :rack_save_keys => "REQUEST_METHOD QUERY_STRING REQUEST_URI",
24
- :rack_unique_req_key => "cas_req_key"
22
+ :rack_session_store => "cas_rack_session",
23
+ :rack_session_key => "rack.session",
24
+ :rack_unique_req_key => "cas_req_key",
25
+ :rack_session_store_timeout => 1,
26
+ :rack_session_store_expires_at_key => "cas_req_expires"
25
27
  }
26
28
  CONFIG_PATH = "#{RAILS_ROOT}/config/cassiopeia.yml"
27
29
  @@conf = {}
@@ -7,6 +7,8 @@ module Cassiopeia
7
7
  CAS_QUERY_STRING_KEY = Cassiopeia::CONFIG[:rack_query_string_key]
8
8
  CAS_SAVE_KEYS = Cassiopeia::CONFIG[:rack_save_keys]
9
9
  CAS_UNIQUE_REQ_KEY = Cassiopeia::CONFIG[:rack_unique_req_key]
10
+ CAS_REQ_EXPIRES_AT_KEY = Cassiopeia::CONFIG[:rack_session_store_expires_at_key]
11
+ CAS_REQ_TIMEOUT = Cassiopeia::CONFIG[:rack_session_store_timeout]
10
12
 
11
13
  def initialize( app )
12
14
  @app = app
@@ -39,13 +41,31 @@ module Cassiopeia
39
41
  env[CAS_QUERY_STRING_KEY] && env[CAS_QUERY_STRING_KEY].match(CAS_TICKET_ID_KEY.to_s) && env[CAS_RACK_SESSION_KEY] && env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE]
40
42
  end
41
43
 
44
+ def remove_expired_headers(env)
45
+ if(env[CAS_RACK_SESSION_KEY] && env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE])
46
+ stores = env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE]
47
+ stores.each do |key, store|
48
+ if store && store[CAS_REQ_EXPIRES_AT_KEY] && store[CAS_REQ_EXPIRES_AT_KEY] >= DateTime.now
49
+ stores.delete key
50
+ end
51
+ end
52
+ end
53
+ end
54
+
55
+ def generate_expiration
56
+ DateTime.now() + CAS_REQ_TIMEOUT / 24.0 / 60.0
57
+ end
58
+
42
59
  def save_headers(env)
43
60
  if(env[CAS_RACK_SESSION_KEY])
61
+ remove_expired_headers(env)
44
62
  req_key = store_req_key(env)
45
- env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE] = { req_key => {}}
63
+ env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE] = {} unless env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE]
64
+ store = env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE]
65
+ store[req_key] = { CAS_REQ_EXPIRES_AT_KEY => generate_expiration }
46
66
  env.each do |key,value|
47
67
  if env[key] && (key.is_a? String) && (key.match("HTTP_") || CAS_SAVE_KEYS.match(key))
48
- env[CAS_RACK_SESSION_KEY][CAS_RACK_SESSION_STORE][req_key][key] = value
68
+ store[req_key][key] = value
49
69
  end
50
70
  end
51
71
  end
data/lib/cassiopeia.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
3
  module Cassiopeia
4
- VERSION = '0.0.8'
4
+ VERSION = '0.0.9'
5
5
  autoload :User, 'cassiopeia/user'
6
6
  autoload :Base, 'cassiopeia/base'
7
7
  autoload :Exception, 'cassiopeia/base'
@@ -19,7 +19,7 @@ module Cassiopeia
19
19
  ActiveRecord::Base.send :extend, ActiveRecordServerMixin
20
20
  ActionController::Base.send :extend, ActionControllerClientMixin
21
21
  Rails.configuration.middleware.use RackRestoreRequest if CONFIG[:service_id]
22
- puts "Cassiopeia 0.0.8 enabled"
22
+ puts "Cassiopeia 0.0.9 enabled"
23
23
  end
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassiopeia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - smecsia
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2010-04-08 00:00:00 +04:00
12
+ date: 2010-04-09 00:00:00 +04:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency