omniauth-cas 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +19 -1
- data/lib/omniauth/cas/version.rb +1 -1
- data/lib/omniauth/strategies/cas.rb +12 -1
- data/spec/omniauth/strategies/cas_spec.rb +20 -6
- metadata +20 -20
data/README.md
CHANGED
@@ -22,7 +22,25 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
|
25
|
+
Use like any other OmniAuth strategy:
|
26
|
+
|
27
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
28
|
+
provider :cas, :host => 'cas.yourdomain.com'
|
29
|
+
end
|
30
|
+
|
31
|
+
OmniAuth CAS requires at least one of the following two configuration options:
|
32
|
+
|
33
|
+
* `host` - Defines the host of your CAS server. A default login URL of `/login` will be assumed.
|
34
|
+
* `login_url` - Defines the URL used to prompt users for their login information.
|
35
|
+
If no `host` is configured, the host application's domain will be used.
|
36
|
+
|
37
|
+
Other configuration options:
|
38
|
+
|
39
|
+
* `port` - The port to use for your configured CAS `host`
|
40
|
+
* `ssl` - TRUE to connect to your CAS server over SSL.
|
41
|
+
* `service_validate_url` - The URL to use to validate a user. Defaults to `/serviceValidate`
|
42
|
+
* `logout_url` - The URL to use to logout a user. Defaults to '/logout'
|
43
|
+
* `uid_key` - The user data attribute to use as your user's unique identifier. Defaults to `user` (usually their login name)
|
26
44
|
|
27
45
|
## Contributing
|
28
46
|
|
data/lib/omniauth/cas/version.rb
CHANGED
@@ -68,10 +68,12 @@ module OmniAuth
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def request_phase
|
71
|
+
service_url = append_params( callback_url, return_url )
|
72
|
+
|
71
73
|
[
|
72
74
|
302,
|
73
75
|
{
|
74
|
-
'Location' => login_url(
|
76
|
+
'Location' => login_url( service_url ),
|
75
77
|
'Content-Type' => 'text/plain'
|
76
78
|
},
|
77
79
|
["You are being redirected to CAS for sign-in."]
|
@@ -167,6 +169,15 @@ module OmniAuth
|
|
167
169
|
# ap "CREDENTIALS"
|
168
170
|
# end
|
169
171
|
|
172
|
+
def return_url
|
173
|
+
# If the request already has a `url` parameter, then it will already be appended to the callback URL.
|
174
|
+
if request.params and request.params['url']
|
175
|
+
{}
|
176
|
+
else
|
177
|
+
{ :url => request.referer }
|
178
|
+
end
|
179
|
+
end
|
180
|
+
|
170
181
|
end
|
171
182
|
end
|
172
183
|
end
|
@@ -12,20 +12,34 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
|
|
12
12
|
}.to_app
|
13
13
|
end
|
14
14
|
|
15
|
-
|
15
|
+
shared_examples_for "a CAS redirect response" do
|
16
|
+
let(:redirect_params) { "service=" + CGI.escape("http://example.org/auth/cas/callback?url=#{return_url}") }
|
16
17
|
before do
|
17
|
-
get
|
18
|
-
end
|
19
|
-
|
20
|
-
let(:redirect_params) { "service=" + CGI.escape("http://example.org/auth/cas/callback?url=http://myapp.com/admin/foo") }
|
18
|
+
get url, nil, request_env
|
19
|
+
end
|
21
20
|
subject { last_response }
|
22
|
-
|
23
21
|
it { should be_redirect }
|
24
22
|
it "should redirect to the CAS server" do
|
25
23
|
subject.headers['Location'].should == "https://cas.example.org/login?" + redirect_params
|
26
24
|
end
|
27
25
|
end
|
28
26
|
|
27
|
+
describe 'GET /auth/cas' do
|
28
|
+
let(:return_url) { 'http://myapp.com/admin/foo' }
|
29
|
+
|
30
|
+
context "with a referer" do
|
31
|
+
let(:url) { '/auth/cas' }
|
32
|
+
let(:request_env) { { 'HTTP_REFERER' => return_url } }
|
33
|
+
it_behaves_like "a CAS redirect response"
|
34
|
+
end
|
35
|
+
context "with an explicit return URL", :focus => true do
|
36
|
+
let(:url) { "/auth/cas?url=#{return_url}" }
|
37
|
+
let(:request_env) { {} }
|
38
|
+
|
39
|
+
it_behaves_like "a CAS redirect response"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
29
43
|
describe 'GET /auth/cas/callback without a ticket' do
|
30
44
|
before do
|
31
45
|
get '/auth/cas/callback'
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-cas
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2012-01-03 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156670480 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '1.0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156670480
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156669980 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '1.5'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2156669980
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: addressable
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156669460 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '2.2'
|
44
44
|
type: :runtime
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2156669460
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156668920 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0.9'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2156668920
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: webmock
|
60
|
-
requirement: &
|
60
|
+
requirement: &2156668300 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.7'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2156668300
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &2156667620 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ~>
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: 0.5.4
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *2156667620
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &2156666940 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.7'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2156666940
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rack-test
|
93
|
-
requirement: &
|
93
|
+
requirement: &2156666480 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ~>
|
@@ -98,10 +98,10 @@ dependencies:
|
|
98
98
|
version: '0.6'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *2156666480
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: awesome_print
|
104
|
-
requirement: &
|
104
|
+
requirement: &2156666080 !ruby/object:Gem::Requirement
|
105
105
|
none: false
|
106
106
|
requirements:
|
107
107
|
- - ! '>='
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0'
|
110
110
|
type: :development
|
111
111
|
prerelease: false
|
112
|
-
version_requirements: *
|
112
|
+
version_requirements: *2156666080
|
113
113
|
description:
|
114
114
|
email:
|
115
115
|
- dlindahl@customink.com
|