rack-cas 0.4.3 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.markdown +16 -0
- data/lib/rack-cas/cas_request.rb +10 -0
- data/lib/rack-cas/railtie.rb +1 -1
- data/lib/rack-cas/version.rb +1 -1
- data/lib/rack/cas.rb +5 -1
- data/lib/rack/fake_cas.rb +7 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40ea6829e44c2f3fbb046bd53f64eba0a7b0c490
|
4
|
+
data.tar.gz: 6acbdc1877f6268ef3d30d6b1c2653dd552d1250
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24871eb8f49e6e7e5a1ffb74d5b3c86b8016e446d32b092f7593e91c6d6fbd5ae4022a54d620ade4167e1b7659509c36ce5d00980a1a393dc0f2a1a2d804472e
|
7
|
+
data.tar.gz: da1d0360a7bc1d17fc1367950b4d6986af11a84e610c28673af18b5bf1c647cf794cf797c530ff59686daea2e1f8b408c60ea4966b63336b8d091c2ef53a46d8
|
data/README.markdown
CHANGED
@@ -80,6 +80,22 @@ Add the following to your `config.ru` file:
|
|
80
80
|
|
81
81
|
Single sign out support outside of Rails is currently untested. We'll be adding instructions here soon.
|
82
82
|
|
83
|
+
Configuration
|
84
|
+
=============
|
85
|
+
|
86
|
+
Excluding Paths
|
87
|
+
---------------
|
88
|
+
|
89
|
+
If you have some parts of your app that should not be CAS authenticated (such as an API namespace), just pass `exclude_path` to the middleware. You can pass in a string that matches the beginning of the path, a regular expression or an array of strings and regular expressions.
|
90
|
+
|
91
|
+
use Rack::CAS, server_url: '...', exclude_path: '/api'
|
92
|
+
use Rack::CAS, server_url: '...', exclude_path: /\.json/
|
93
|
+
use Rack::CAS, server_url: '...', exclude_paths: ['/api', /\.json/]
|
94
|
+
|
95
|
+
The same options can be passed to `FakeCAS`.
|
96
|
+
|
97
|
+
use Rack::FakeCAS, exclude_path: '/api'
|
98
|
+
|
83
99
|
Integration
|
84
100
|
===========
|
85
101
|
Your app should __return a [401 status](http://httpstatus.es/401)__ whenever a request is made that requires authentication. Rack-CAS will catch these responses and attempt to authenticate via your CAS server.
|
data/lib/rack-cas/cas_request.rb
CHANGED
@@ -31,6 +31,16 @@ class CASRequest
|
|
31
31
|
!!(@request.get? && ticket_param && ticket_param.to_s =~ /\AST\-[^\s]{29}/)
|
32
32
|
end
|
33
33
|
|
34
|
+
def path_matches?(strings_or_regexps)
|
35
|
+
Array(strings_or_regexps).any? do |matcher|
|
36
|
+
if matcher.is_a? Regexp
|
37
|
+
!!(@request.path_info =~ matcher)
|
38
|
+
elsif matcher.to_s != ''
|
39
|
+
@request.path_info[0...matcher.to_s.length] == matcher.to_s
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
34
44
|
private
|
35
45
|
|
36
46
|
def ticket_param
|
data/lib/rack-cas/railtie.rb
CHANGED
@@ -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
|
8
|
+
app.middleware.use Rack::FakeCAS, config.rack_cas
|
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
|
data/lib/rack-cas/version.rb
CHANGED
data/lib/rack/cas.rb
CHANGED
@@ -10,7 +10,7 @@ class Rack::CAS
|
|
10
10
|
@app = app
|
11
11
|
@server_url = config.delete(:server_url)
|
12
12
|
@session_store = config.delete(:session_store)
|
13
|
-
@config = config
|
13
|
+
@config = config || {}
|
14
14
|
|
15
15
|
raise ArgumentError, 'server_url is required' if @server_url.nil?
|
16
16
|
if @session_store && !@session_store.respond_to?(:destroy_session_by_cas_ticket)
|
@@ -22,6 +22,10 @@ class Rack::CAS
|
|
22
22
|
request = Rack::Request.new(env)
|
23
23
|
cas_request = CASRequest.new(request)
|
24
24
|
|
25
|
+
if cas_request.path_matches? @config[:exclude_paths] || @config[:exclude_path]
|
26
|
+
return @app.call(env)
|
27
|
+
end
|
28
|
+
|
25
29
|
if cas_request.ticket_validation?
|
26
30
|
log env, 'rack-cas: Intercepting ticket validation request.'
|
27
31
|
|
data/lib/rack/fake_cas.rb
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
require 'rack'
|
2
|
+
require 'rack-cas/cas_request'
|
2
3
|
|
3
4
|
class Rack::FakeCAS
|
4
5
|
def initialize(app, config={})
|
5
6
|
@app = app
|
6
|
-
@config = config
|
7
|
+
@config = config || {}
|
7
8
|
end
|
8
9
|
|
9
10
|
def call(env)
|
10
11
|
@request = Rack::Request.new(env)
|
12
|
+
cas_request = CASRequest.new(@request)
|
13
|
+
|
14
|
+
if cas_request.path_matches? @config[:exclude_paths] || @config[:exclude_path]
|
15
|
+
return @app.call(env)
|
16
|
+
end
|
11
17
|
|
12
18
|
case @request.path_info
|
13
19
|
when '/login'
|
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.5.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-
|
11
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|