rack-cas 0.15.0 → 0.16.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +18 -0
- data/lib/rack-cas/configuration.rb +2 -2
- data/lib/rack-cas/saml_validation_response.rb +1 -1
- data/lib/rack-cas/session_store/active_record.rb +1 -1
- data/lib/rack-cas/session_store/rack/redis.rb +10 -0
- data/lib/rack-cas/session_store/rails/redis.rb +10 -0
- data/lib/rack-cas/session_store/redis.rb +109 -0
- data/lib/rack-cas/version.rb +1 -1
- metadata +8 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0d93b9b6cfd9a88b23291eb5c3babac6313c7bcd
|
4
|
+
data.tar.gz: 397e001a435e2944c8c49e3390237d485abd8897
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be21fd7776d5e5b81ba56e776db5585381d301904c80737d85faeeb23adf0f7689665e9fdcb2e9acbaf6bdac928c02a7ac2e41d67c785dfde5884d62c00615df
|
7
|
+
data.tar.gz: a5362ad32fd9e7ac13c701f4d6865b5f74ad5726b2f7cd7008776703cee29e8da2614af3cceed1913b1445cee3b9787edaaca539b4b1d1aa30995c6a9d859172
|
data/README.md
CHANGED
@@ -77,6 +77,24 @@ Edit your `config/initializers/session_store.rb` file with the following:
|
|
77
77
|
require 'rack-cas/session_store/rails/mongoid'
|
78
78
|
YourApp::Application.config.session_store ActionDispatch::Session::RackCasMongoidStore
|
79
79
|
```
|
80
|
+
#### Redis ####
|
81
|
+
|
82
|
+
Set the `session_store` in your `config/application.rb`:
|
83
|
+
```ruby
|
84
|
+
require 'rack-cas/session_store/redis'
|
85
|
+
config.rack_cas.session_store = RackCAS::RedisStore
|
86
|
+
```
|
87
|
+
Edit your `config/initializers/session_store.rb` file with the following:
|
88
|
+
```ruby
|
89
|
+
require 'rack-cas/session_store/rails/redis'
|
90
|
+
YourApp::Application.config.session_store ActionDispatch::Session::RackCasRedisStore
|
91
|
+
```
|
92
|
+
Optionally, Set the `redis_options` in your `config/application.rb`.
|
93
|
+
You can specify anything `Redis.new` allows.
|
94
|
+
For example:
|
95
|
+
```ruby
|
96
|
+
config.rack_cas.redis_options = {path: '/tmp/redis.sock',driver: :hiredis}
|
97
|
+
```
|
80
98
|
Sinatra and Other Rack-Compatible Frameworks
|
81
99
|
--------------------------------------------
|
82
100
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module RackCAS
|
2
2
|
class Configuration
|
3
|
-
SETTINGS = [:fake, :server_url, :session_store, :exclude_path, :exclude_paths, :extra_attributes_filter,
|
4
|
-
:verify_ssl_cert, :renew, :use_saml_validation, :ignore_intercept_validator, :exclude_request_validator, :protocol]
|
3
|
+
SETTINGS = [:fake, :fake_attributes, :server_url, :session_store, :exclude_path, :exclude_paths, :extra_attributes_filter,
|
4
|
+
:verify_ssl_cert, :renew, :use_saml_validation, :ignore_intercept_validator, :exclude_request_validator, :protocol,:redis_options]
|
5
5
|
|
6
6
|
|
7
7
|
SETTINGS.each do |setting|
|
@@ -44,7 +44,7 @@ module RackCAS
|
|
44
44
|
protected
|
45
45
|
|
46
46
|
def success?
|
47
|
-
@success ||= xml.at('//Response/Status/StatusCode/@Value').text
|
47
|
+
@success ||= xml.at('//Response/Status/StatusCode/@Value').text =~ /saml1?p:Success/
|
48
48
|
end
|
49
49
|
|
50
50
|
def authentication_failure
|
@@ -0,0 +1,109 @@
|
|
1
|
+
module RackCAS
|
2
|
+
module RedisStore
|
3
|
+
class Session
|
4
|
+
@client = nil
|
5
|
+
|
6
|
+
def self.client
|
7
|
+
@client ||= (RackCAS.config.redis_options? ? Redis.new(RackCAS.config.redis_options) : Redis.new)
|
8
|
+
return @client
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.find_by_id(session_id)
|
12
|
+
session = self.client.get("rack_cas_session:#{session_id}")
|
13
|
+
session ? {'sid' => session_id, 'data' => session} : session
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.write(session_id:, data:, cas_ticket: )
|
17
|
+
#create a row with the session_id and the data
|
18
|
+
#create a row with the cas_ticket acting as a reverse index
|
19
|
+
results = self.client.pipelined do
|
20
|
+
self.client.set("rack_cas_session:#{session_id}",data)
|
21
|
+
self.client.expireat("rack_cas_session:#{session_id}",30.days.from_now.to_i)
|
22
|
+
self.client.set("rack_cas_ticket:#{cas_ticket}","rack_cas_session:#{session_id}")
|
23
|
+
self.client.expireat("rack_cas_ticket:#{cas_ticket}",30.days.from_now.to_i)
|
24
|
+
end
|
25
|
+
|
26
|
+
results == ["OK",true,"OK",true] ? session_id : false
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.destroy_by_cas_ticket(cas_ticket)
|
30
|
+
session_id = self.client.get("rack_cas_ticket:#{cas_ticket}")
|
31
|
+
results = self.client.pipelined do
|
32
|
+
self.client.del("rack_cas_ticket:#{cas_ticket}")
|
33
|
+
self.client.del(session_id)
|
34
|
+
end
|
35
|
+
return results[1]
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.delete(session_id)
|
39
|
+
self.client.del("rack_cas_session:#{session_id}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.destroy_session_by_cas_ticket(cas_ticket)
|
44
|
+
affected = Session.destroy_by_cas_ticket(cas_ticket)
|
45
|
+
affected == 1
|
46
|
+
end
|
47
|
+
|
48
|
+
#we don't need to prune because the keys expire automatically
|
49
|
+
def self.prune(after = nil)
|
50
|
+
end
|
51
|
+
|
52
|
+
private
|
53
|
+
|
54
|
+
|
55
|
+
# Rack 2.0 method
|
56
|
+
def find_session(env, sid)
|
57
|
+
if sid.nil?
|
58
|
+
sid = generate_sid
|
59
|
+
data = nil
|
60
|
+
else
|
61
|
+
unless session = Session.find_by_id(sid)
|
62
|
+
session = {}
|
63
|
+
# force generation of new sid since there is no associated session
|
64
|
+
sid = generate_sid
|
65
|
+
end
|
66
|
+
data = unpack(session['data'])
|
67
|
+
end
|
68
|
+
|
69
|
+
[sid, data]
|
70
|
+
end
|
71
|
+
|
72
|
+
# Rack 2.0 method
|
73
|
+
def write_session(env, sid, session_data, options)
|
74
|
+
cas_ticket = (session_data['cas']['ticket'] unless session_data['cas'].nil?)
|
75
|
+
|
76
|
+
success = Session.write(session_id: sid, data: pack(session_data), cas_ticket: cas_ticket)
|
77
|
+
|
78
|
+
success ? sid : false
|
79
|
+
end
|
80
|
+
|
81
|
+
# Rack 2.0 method
|
82
|
+
def delete_session(env, sid, options)
|
83
|
+
Session.delete(sid)
|
84
|
+
|
85
|
+
options[:drop] ? nil : generate_sid
|
86
|
+
end
|
87
|
+
|
88
|
+
# Rack 1.* method
|
89
|
+
alias get_session find_session
|
90
|
+
|
91
|
+
# Rack 1.* method
|
92
|
+
def set_session(env, sid, session_data, options) # rack 1.x compatibilty
|
93
|
+
write_session(Rack::Request.new(env), sid, session_data, options)
|
94
|
+
end
|
95
|
+
|
96
|
+
# Rack 1.* method
|
97
|
+
def destroy_session(env, sid, options) # rack 1.x compatibilty
|
98
|
+
delete_session(Rack::Request.new(env), sid, options)
|
99
|
+
end
|
100
|
+
|
101
|
+
def pack(data)
|
102
|
+
::Base64.encode64(Marshal.dump(data)) if data
|
103
|
+
end
|
104
|
+
|
105
|
+
def unpack(data)
|
106
|
+
Marshal.load(::Base64.decode64(data)) if data
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
data/lib/rack-cas/version.rb
CHANGED
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.
|
4
|
+
version: 0.16.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:
|
11
|
+
date: 2017-09-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -100,14 +100,14 @@ dependencies:
|
|
100
100
|
requirements:
|
101
101
|
- - "~>"
|
102
102
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
103
|
+
version: '2.3'
|
104
104
|
type: :development
|
105
105
|
prerelease: false
|
106
106
|
version_requirements: !ruby/object:Gem::Requirement
|
107
107
|
requirements:
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
110
|
+
version: '2.3'
|
111
111
|
description: Simple CAS authentication for Rails, Sinatra or any Rack-based site
|
112
112
|
email: adam@codenoble.com
|
113
113
|
executables: []
|
@@ -129,8 +129,11 @@ files:
|
|
129
129
|
- lib/rack-cas/session_store/mongoid.rb
|
130
130
|
- lib/rack-cas/session_store/rack/active_record.rb
|
131
131
|
- lib/rack-cas/session_store/rack/mongoid.rb
|
132
|
+
- lib/rack-cas/session_store/rack/redis.rb
|
132
133
|
- lib/rack-cas/session_store/rails/active_record.rb
|
133
134
|
- lib/rack-cas/session_store/rails/mongoid.rb
|
135
|
+
- lib/rack-cas/session_store/rails/redis.rb
|
136
|
+
- lib/rack-cas/session_store/redis.rb
|
134
137
|
- lib/rack-cas/url.rb
|
135
138
|
- lib/rack-cas/version.rb
|
136
139
|
- lib/rack/cas.rb
|
@@ -156,9 +159,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
159
|
version: '0'
|
157
160
|
requirements: []
|
158
161
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
162
|
+
rubygems_version: 2.6.11
|
160
163
|
signing_key:
|
161
164
|
specification_version: 4
|
162
165
|
summary: Rack-based CAS client
|
163
166
|
test_files: []
|
164
|
-
has_rdoc:
|