rack-cas 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0d93b9b6cfd9a88b23291eb5c3babac6313c7bcd
4
- data.tar.gz: 397e001a435e2944c8c49e3390237d485abd8897
2
+ SHA256:
3
+ metadata.gz: af1e3b165fc96ee826408cdb92a8b75efde25142bfe3a723b637427bedd14a8b
4
+ data.tar.gz: a81f1d05e4eadedf53aa97bdae224345c0e969370a4b6f399e465b43229793d9
5
5
  SHA512:
6
- metadata.gz: be21fd7776d5e5b81ba56e776db5585381d301904c80737d85faeeb23adf0f7689665e9fdcb2e9acbaf6bdac928c02a7ac2e41d67c785dfde5884d62c00615df
7
- data.tar.gz: a5362ad32fd9e7ac13c701f4d6865b5f74ad5726b2f7cd7008776703cee29e8da2614af3cceed1913b1445cee3b9787edaaca539b4b1d1aa30995c6a9d859172
6
+ metadata.gz: 763c339ba9e541aa94401135f471b475434816fee5287fb84a1a8adefcd0ed098bcfdfcad64737891c9075aa99cddc173ee75bbc81c6bae464a33f74181a87e3
7
+ data.tar.gz: 689db6c253c92114a9609ccfa870da73816fc3d684e744a63521d15ee52f814298c8137f7b49bf178ed385c45104ff00aec02f406c96bd9a9a4e2ec1c1cf58eb
data/README.md CHANGED
@@ -18,7 +18,7 @@ One of the included session stores must be used.
18
18
 
19
19
  Requirements
20
20
  ============
21
- * Ruby >= 1.9.2
21
+ * Ruby >= 2.0
22
22
  * A working [CAS server](http://casino.rbcas.com)
23
23
  * An app that [returns a `401 Unauthorized`](#integration) status when authentication is required
24
24
 
@@ -109,7 +109,7 @@ See the [example Sinatra app](https://gist.github.com/adamcrown/a7e7577594690335
109
109
 
110
110
  ### Single Sign Out ###
111
111
 
112
- You will need to store sessions in session store supported by Rack CAS.
112
+ You will need to store sessions in session store supported by Rack CAS.
113
113
 
114
114
  #### Active Record ####
115
115
  Add a migration that looks roughly like
@@ -168,6 +168,15 @@ a `Rack::Request` object as a parameter.
168
168
  use Rack::CAS, server_url: '...', exclude_request_validator: Proc.new { |req| req.env['HTTP_CONTENT_TYPE'] == 'application/json' }
169
169
  ```
170
170
 
171
+ Service URL
172
+ --------------------
173
+
174
+ Sometimes you need to force the `service=` attribute on login requests, and not just use the request url in an automatic way.
175
+
176
+ ```ruby
177
+ use Rack::CAS, service: 'http://anotherexample.com'
178
+ ```
179
+
171
180
  Ignore 401 Intercept
172
181
  --------------------
173
182
 
@@ -1,7 +1,8 @@
1
1
  module RackCAS
2
2
  class Configuration
3
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]
4
+ :verify_ssl_cert, :renew, :use_saml_validation, :ignore_intercept_validator, :exclude_request_validator, :protocol,
5
+ :redis_options, :login_url, :service]
5
6
 
6
7
 
7
8
  SETTINGS.each do |setting|
@@ -13,7 +13,8 @@ module RackCAS
13
13
  base_params = {service: service_url}
14
14
  base_params[:renew] = true if RackCAS.config.renew?
15
15
 
16
- @url.dup.append_path('login').add_params(base_params.merge(params))
16
+ url = RackCAS.config.login_url? ? RackCAS::URL.parse(RackCAS.config.login_url) : @url.dup.append_path('login')
17
+ url.add_params(base_params.merge(params))
17
18
  end
18
19
 
19
20
  def logout_url(params = {})
@@ -1,3 +1,3 @@
1
1
  module RackCAS
2
- VERSION = '0.16.0'
2
+ VERSION = '0.16.1'
3
3
  end
@@ -21,16 +21,18 @@ class Rack::CAS
21
21
  if cas_request.ticket_validation?
22
22
  log env, 'rack-cas: Intercepting ticket validation request.'
23
23
 
24
+ service_url = RackCAS.config.service? ? RackCAS.config.service : cas_request.service_url
25
+
24
26
  begin
25
27
  user, extra_attrs = get_user(request.url, cas_request.ticket)
26
28
  rescue RackCAS::ServiceValidationResponse::TicketInvalidError, RackCAS::SAMLValidationResponse::TicketInvalidError
27
29
  log env, 'rack-cas: Invalid ticket. Redirecting to CAS login.'
28
30
 
29
- return redirect_to server.login_url(cas_request.service_url).to_s
31
+ return redirect_to server.login_url(service_url).to_s
30
32
  end
31
33
 
32
34
  store_session request, user, cas_request.ticket, extra_attrs
33
- return redirect_to cas_request.service_url
35
+ return redirect_to service_url
34
36
  end
35
37
 
36
38
  if cas_request.logout?
@@ -52,7 +54,17 @@ class Rack::CAS
52
54
  if response[0] == 401 && !ignore_intercept?(request) # access denied
53
55
  log env, 'rack-cas: Intercepting 401 access denied response. Redirecting to CAS login.'
54
56
 
55
- redirect_to server.login_url(request.url).to_s
57
+ url = if RackCAS.config.service?
58
+ configured_service_url = RackCAS::URL.parse(RackCAS.config.service)
59
+ request_url = RackCAS::URL.parse(request.url)
60
+ request_url.host = configured_service_url.host
61
+ request_url.scheme = configured_service_url.scheme
62
+ request_url.to_s
63
+ else
64
+ cas_request.service_url
65
+ end
66
+
67
+ redirect_to server.login_url(url).to_s
56
68
  else
57
69
  response
58
70
  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.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Crownoble
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-18 00:00:00.000000000 Z
11
+ date: 2019-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack
@@ -151,15 +151,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
151
151
  requirements:
152
152
  - - ">="
153
153
  - !ruby/object:Gem::Version
154
- version: '0'
154
+ version: 2.0.0
155
155
  required_rubygems_version: !ruby/object:Gem::Requirement
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
159
  version: '0'
160
160
  requirements: []
161
- rubyforge_project:
162
- rubygems_version: 2.6.11
161
+ rubygems_version: 3.0.3
163
162
  signing_key:
164
163
  specification_version: 4
165
164
  summary: Rack-based CAS client