rack-cas 0.8.1 → 0.9.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: 1cf9f06c6db0201c3d5bcadb8158c390622630cf
4
- data.tar.gz: 1fc8eb9bbf210d5de67d3e68d4b4f99a0f2118ad
3
+ metadata.gz: be59f7030ccb7a62223fbddaa9529f50765ba0b0
4
+ data.tar.gz: 8e1a4ea3773a8b7306f328a5406a61c01404812d
5
5
  SHA512:
6
- metadata.gz: 253fa6cc882ad0f229f5ae470e422111949bd8255490c9db21f24a491df6d8f234915309b0fe59057ec727e3a15d9759d44bbcfe14455b3cbc4db026536d84f5
7
- data.tar.gz: 1741c9fe41dc735907fc1a5483687302a9cee328c3787b483e440720d5f5c07f54c9a86589d4e9a2d10a6da6351d1faf1788d09f89da182156590f593f4a77e8
6
+ metadata.gz: 78f0a1a537f74cf2b9af832e8fa5262b8f9738a82b2d2d556f720f151cfb1bb61612d03bca63240e77ce21715e517c072cd632d60266fa4a9a7ee79c1c4722de
7
+ data.tar.gz: bb51611875bb791f5589b3ea2f0277afb9ac1d65ea3ff2f417b9e72fe9d3289b04184155c7b0e0ca7c92b9ac7b2334a5acb2d842f68bbb7317606ce4a057fce2
data/README.markdown CHANGED
@@ -5,15 +5,15 @@ Rack-CAS is simple [Rack](http://rack.github.com/) middleware to perform [CAS](h
5
5
  Features
6
6
  ========
7
7
  * __Rack based__
8
- * __Framework independent__
8
+ * __Framework independent__
9
9
  Works with, but doesn't depend on Rails, Sinatra, etc.
10
- * __Minimal dependencies__
10
+ * __Minimal dependencies__
11
11
  Current gem dependencies are [rack](http://rubygems.org/gems/rack), [addressable](http://rubygems.org/gems/addressable) and [nokogiri](http://rubygems.org/gems/nokogiri).
12
- * __Supports CAS extra attributes__
12
+ * __Supports CAS extra attributes__
13
13
  Extra attributes are a mess though. So let me know if your brand of CAS server isn't supported.
14
- * __Single sign out__
14
+ * __Single sign out__
15
15
  One of the included session stores must be used.
16
- * __Rake tasks to prune stale sessions__
16
+ * __Rake tasks to prune stale sessions__
17
17
  `rack_cas:sessions:prune:active_record` and `rack_cas:sessions:prune:mongoid`
18
18
 
19
19
  Requirements
@@ -128,10 +128,19 @@ Integration testing using something like [Capybara](http://jnicklas.github.com/c
128
128
  require 'rack/fake_cas'
129
129
  use Rack::FakeCAS
130
130
 
131
+ In addition you can pass a Hash to configure extra attributes for predefined
132
+ usernames.
133
+
134
+ use Rack::FakeCAS, {}, {'john' => {'name' => 'John Doe'}}
135
+
131
136
  If you are using Rails, FakeCAS is automatically used in the test environment by default. If you would like to activate it in any other environment, add the following to the corresponding `config/environments/<env>.rb`:
132
137
 
133
138
  config.rack_cas.fake = true
134
139
 
140
+ You can also configure extra attribute mappings through the Rails config:
141
+
142
+ config.rack_cas.fake_attributes = { 'john' => { 'name' => 'John Doe' } }
143
+
135
144
  Then you can simply do the following in your integration tests in order to log in.
136
145
 
137
146
  visit '/restricted_path'
@@ -5,7 +5,7 @@ module RackCAS
5
5
  initializer 'rack_cas.initialize' do |app|
6
6
  if config.rack_cas.fake || (config.rack_cas.fake.nil? && Rails.env.test?)
7
7
  require 'rack/fake_cas'
8
- app.middleware.use Rack::FakeCAS, config.rack_cas
8
+ app.middleware.use Rack::FakeCAS, config.rack_cas, config.rack_cas.fake_attributes
9
9
  elsif !config.rack_cas.server_url.nil? # for backwards compatibility
10
10
  require 'rack/cas'
11
11
  app.middleware.use Rack::CAS, config.rack_cas
@@ -16,4 +16,4 @@ module RackCAS
16
16
  load File.expand_path('../../tasks/session_prune.rake', __FILE__)
17
17
  end
18
18
  end
19
- end
19
+ end
@@ -30,18 +30,20 @@ module RackCAS
30
30
  def set_session(env, sid, session_data, options)
31
31
  cas_ticket = (session_data['cas']['ticket'] unless session_data['cas'].nil?)
32
32
 
33
- session = if ActiveRecord.version >= Gem::Version.new('4.0.0')
33
+ session = if ActiveRecord.respond_to?(:version) && ActiveRecord.version >= Gem::Version.new('4.0.0')
34
34
  Session.where(session_id: sid).first_or_initialize
35
35
  else
36
36
  Session.find_or_initialize_by_session_id(sid)
37
37
  end
38
- success = session.update_attributes(data: pack(session_data), cas_ticket: cas_ticket)
38
+ session.data = pack(session_data)
39
+ session.cas_ticket = cas_ticket
40
+ success = session.save
39
41
 
40
42
  success ? session.session_id : false
41
43
  end
42
44
 
43
45
  def destroy_session(env, sid, options)
44
- session = Session.where(session_id: sid).delete_all
46
+ Session.where(session_id: sid).delete_all
45
47
 
46
48
  options[:drop] ? nil : generate_sid
47
49
  end
@@ -1,3 +1,3 @@
1
1
  module RackCAS
2
- VERSION = '0.8.1'
2
+ VERSION = '0.9.0'
3
3
  end
data/lib/rack/fake_cas.rb CHANGED
@@ -2,9 +2,10 @@ require 'rack'
2
2
  require 'rack-cas/cas_request'
3
3
 
4
4
  class Rack::FakeCAS
5
- def initialize(app, config={})
5
+ def initialize(app, config={}, attributes_config={})
6
6
  @app = app
7
7
  @config = config || {}
8
+ @attributes_config = attributes_config || {}
8
9
  end
9
10
 
10
11
  def call(env)
@@ -14,12 +15,13 @@ class Rack::FakeCAS
14
15
  if cas_request.path_matches? @config[:exclude_paths] || @config[:exclude_path]
15
16
  return @app.call(env)
16
17
  end
17
-
18
+
18
19
  case @request.path_info
19
20
  when '/login'
21
+ username = @request.params['username']
20
22
  @request.session['cas'] = {}
21
- @request.session['cas']['user'] = @request.params['username']
22
- @request.session['cas']['extra_attributes'] = {}
23
+ @request.session['cas']['user'] = username
24
+ @request.session['cas']['extra_attributes'] = @attributes_config.fetch(username, {})
23
25
  redirect_to @request.params['service']
24
26
 
25
27
  when '/logout'
@@ -64,4 +66,4 @@ class Rack::FakeCAS
64
66
  def redirect_to(url)
65
67
  [ 302, { 'Content-Type' => 'text/plain', 'Location' => url }, ['Redirecting you...'] ]
66
68
  end
67
- end
69
+ end
metadata CHANGED
@@ -1,129 +1,130 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-cas
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
4
+ version: 0.9.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-08-30 00:00:00.000000000 Z
11
+ date: 2014-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.3'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '2.3'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '2.3'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: nokogiri
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: '1.5'
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: '1.5'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - ~>
59
+ - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: 2.11.0
61
+ version: '2.11'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - ~>
66
+ - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: 2.11.0
68
+ version: '2.11'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rack-test
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - '>='
73
+ - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0'
75
+ version: '0.6'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - '>='
80
+ - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0'
82
+ version: '0.6'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - '>='
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '0'
89
+ version: '1.6'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - '>='
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '0'
96
+ version: '1.6'
97
97
  description: Simple CAS authentication for Rails, Sinatra or any Rack-based site
98
98
  email: adam.crownoble@biola.edu
99
99
  executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
102
102
  files:
103
- - README.markdown
104
103
  - MIT-LICENSE
105
- - lib/rack-cas/railtie.rb
106
- - lib/rack-cas/url.rb
107
- - lib/rack-cas/version.rb
108
- - lib/rack-cas/service_validation_response.rb
104
+ - README.markdown
105
+ - lib/generators/cas_session_store_migration_generator.rb
106
+ - lib/generators/templates/migration.rb
107
+ - lib/rack-cas.rb
109
108
  - lib/rack-cas/cas_request.rb
109
+ - lib/rack-cas/railtie.rb
110
110
  - lib/rack-cas/server.rb
111
+ - lib/rack-cas/service_validation_response.rb
111
112
  - lib/rack-cas/session_store/active_record.rb
112
- - lib/rack-cas/session_store/rails/active_record.rb
113
- - lib/rack-cas/session_store/rails/mongo.rb
114
- - lib/rack-cas/session_store/rails/mongoid.rb
115
113
  - lib/rack-cas/session_store/mongo.rb
116
114
  - lib/rack-cas/session_store/mongoid.rb
117
115
  - lib/rack-cas/session_store/rack/mongo.rb
118
116
  - lib/rack-cas/session_store/rack/mongoid.rb
119
- - lib/rack-cas.rb
120
- - lib/generators/cas_session_store_migration_generator.rb
121
- - lib/generators/templates/migration.rb
117
+ - lib/rack-cas/session_store/rails/active_record.rb
118
+ - lib/rack-cas/session_store/rails/mongo.rb
119
+ - lib/rack-cas/session_store/rails/mongoid.rb
120
+ - lib/rack-cas/url.rb
121
+ - lib/rack-cas/version.rb
122
122
  - lib/rack/cas.rb
123
123
  - lib/rack/fake_cas.rb
124
124
  - lib/tasks/session_prune.rake
125
125
  homepage: https://github.com/biola/rack-cas
126
- licenses: []
126
+ licenses:
127
+ - MIT
127
128
  metadata: {}
128
129
  post_install_message:
129
130
  rdoc_options: []
@@ -131,17 +132,17 @@ require_paths:
131
132
  - lib
132
133
  required_ruby_version: !ruby/object:Gem::Requirement
133
134
  requirements:
134
- - - '>='
135
+ - - ">="
135
136
  - !ruby/object:Gem::Version
136
137
  version: '0'
137
138
  required_rubygems_version: !ruby/object:Gem::Requirement
138
139
  requirements:
139
- - - '>='
140
+ - - ">="
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  requirements: []
143
144
  rubyforge_project:
144
- rubygems_version: 2.0.3
145
+ rubygems_version: 2.2.2
145
146
  signing_key:
146
147
  specification_version: 4
147
148
  summary: Rack-based CAS client