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 +1 -0
- data/Rakefile +1 -1
- data/lib/cassiopeia/config.rb +5 -3
- data/lib/cassiopeia/rack_restore_request.rb +22 -2
- data/lib/cassiopeia.rb +2 -2
- metadata +2 -2
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
data/lib/cassiopeia/config.rb
CHANGED
@@ -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
|
-
:
|
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] = {
|
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
|
-
|
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.
|
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.
|
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.
|
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-
|
12
|
+
date: 2010-04-09 00:00:00 +04:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|