omniauth-cas 0.0.3 → 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis.yml +4 -0
- data/README.md +20 -4
- data/lib/omniauth/cas/version.rb +1 -1
- data/lib/omniauth/strategies/cas.rb +5 -2
- data/omniauth-cas.gemspec +1 -1
- data/spec/omniauth/strategies/cas_spec.rb +16 -5
- data/spec/spec_helper.rb +2 -0
- metadata +21 -21
data/README.md
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
-
# OmniAuth CAS Strategy [![Build Status](https://secure.travis-ci.org/dlindahl/omniauth-cas.png)](
|
1
|
+
# OmniAuth CAS Strategy [![Build Status](https://secure.travis-ci.org/dlindahl/omniauth-cas.png)][travis] [![Dependency Status](https://gemnasium.com/dlindahl/omniauth-cas.png?travis)][gemnasium]
|
2
|
+
|
3
|
+
[travis]: http://travis-ci.org/dlindahl/omniauth-cas
|
4
|
+
[gemnasium]: https://gemnasium.com/dlindahl/omniauth-cas
|
2
5
|
|
3
6
|
A CAS Strategy for OmniAuth.
|
4
7
|
|
@@ -6,6 +9,12 @@ I didn't really want to do this, but no one else has, so I might as well give it
|
|
6
9
|
|
7
10
|
This is highly experimental, use at your own risk!
|
8
11
|
|
12
|
+
Having said that, please let me know if you discover any problems or
|
13
|
+
have any feature requests by opening an Issue on the GitHub page. I will try to address
|
14
|
+
them as fast as I can.
|
15
|
+
|
16
|
+
Thanks in advance for trying this out!
|
17
|
+
|
9
18
|
## Installation
|
10
19
|
|
11
20
|
Add this line to your application's Gemfile:
|
@@ -38,9 +47,9 @@ Other configuration options:
|
|
38
47
|
|
39
48
|
* `port` - The port to use for your configured CAS `host`
|
40
49
|
* `ssl` - TRUE to connect to your CAS server over SSL.
|
41
|
-
* `service_validate_url` - The URL to use to validate a user. Defaults to
|
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
|
50
|
+
* `service_validate_url` - The URL to use to validate a user. Defaults to `'/serviceValidate'`
|
51
|
+
* `logout_url` - The URL to use to logout a user. Defaults to `'/logout'`
|
52
|
+
* `uid_key` - The user data attribute to use as your user's unique identifier. Defaults to `'user'` (which usually contains the user's login name)
|
44
53
|
|
45
54
|
## Contributing
|
46
55
|
|
@@ -49,3 +58,10 @@ Other configuration options:
|
|
49
58
|
3. Commit your changes (`git commit -am 'Added some feature'`)
|
50
59
|
4. Push to the branch (`git push origin my-new-feature`)
|
51
60
|
5. Create new Pull Request
|
61
|
+
|
62
|
+
## Thanks
|
63
|
+
|
64
|
+
Special thanks go out to the following people
|
65
|
+
|
66
|
+
* Phillip Aldridge (@iterateNZ) and JB Barth (@jbbarth) for helping out with Issue #3
|
67
|
+
|
data/lib/omniauth/cas/version.rb
CHANGED
@@ -105,6 +105,7 @@ module OmniAuth
|
|
105
105
|
service_url = Addressable::URI.parse( service_url )
|
106
106
|
service_url.query_values = service_url.query_values.tap { |qs| qs.delete('ticket') }
|
107
107
|
|
108
|
+
# cas_host + append_params(@options.service_validate_url, { :service => service_url.to_s, :ticket => ticket })
|
108
109
|
cas_host + append_params(@options.service_validate_url, { :service => service_url.to_s, :ticket => ticket })
|
109
110
|
end
|
110
111
|
|
@@ -114,16 +115,18 @@ module OmniAuth
|
|
114
115
|
#
|
115
116
|
# @return [String] a URL like `http://cas.mycompany.com/login?service=...`
|
116
117
|
def login_url(service)
|
117
|
-
cas_host + append_params( @options.login_url, { :service =>
|
118
|
+
cas_host + append_params( @options.login_url, { :service => service })
|
118
119
|
end
|
119
120
|
|
120
121
|
# Adds URL-escaped +parameters+ to +base+.
|
121
122
|
#
|
122
123
|
# @param [String] base the base URL
|
123
|
-
# @param [String]
|
124
|
+
# @param [String] params the parameters to append to the URL
|
124
125
|
#
|
125
126
|
# @return [String] the new joined URL.
|
126
127
|
def append_params(base, params)
|
128
|
+
params = params.each { |k,v| v = Rack::Utils.escape(v) }
|
129
|
+
|
127
130
|
Addressable::URI.parse(base).tap do |base_uri|
|
128
131
|
base_uri.query_values = (base_uri.query_values || {}).merge( params )
|
129
132
|
end.to_s
|
data/omniauth-cas.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
|
|
15
15
|
gem.require_paths = ["lib"]
|
16
16
|
gem.version = Omniauth::Cas::VERSION
|
17
17
|
|
18
|
-
gem.add_dependency 'omniauth', '~> 1.0'
|
18
|
+
gem.add_dependency 'omniauth', '~> 1.0.2'
|
19
19
|
gem.add_dependency 'nokogiri', '~> 1.5'
|
20
20
|
gem.add_dependency 'addressable', '~> 2.2'
|
21
21
|
|
@@ -12,11 +12,12 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
|
|
12
12
|
}.to_app
|
13
13
|
end
|
14
14
|
|
15
|
+
# TODO: Verify that these are even useful tests
|
15
16
|
shared_examples_for "a CAS redirect response" do
|
16
|
-
let(:redirect_params) { "service=" +
|
17
|
+
let(:redirect_params) { "service=" + Rack::Utils.escape("http://example.org/auth/cas/callback?url=#{Rack::Utils.escape(return_url)}") }
|
17
18
|
before do
|
18
19
|
get url, nil, request_env
|
19
|
-
end
|
20
|
+
end
|
20
21
|
subject { last_response }
|
21
22
|
it { should be_redirect }
|
22
23
|
it "should redirect to the CAS server" do
|
@@ -32,10 +33,10 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
|
|
32
33
|
let(:request_env) { { 'HTTP_REFERER' => return_url } }
|
33
34
|
it_behaves_like "a CAS redirect response"
|
34
35
|
end
|
35
|
-
context "with an explicit return URL"
|
36
|
+
context "with an explicit return URL" do
|
36
37
|
let(:url) { "/auth/cas?url=#{return_url}" }
|
37
38
|
let(:request_env) { {} }
|
38
|
-
|
39
|
+
|
39
40
|
it_behaves_like "a CAS redirect response"
|
40
41
|
end
|
41
42
|
end
|
@@ -69,17 +70,27 @@ describe OmniAuth::Strategies::CAS, :type => :strategy do
|
|
69
70
|
end
|
70
71
|
|
71
72
|
describe 'GET /auth/cas/callback with a valid ticket' do
|
73
|
+
let(:return_url) { "http://127.0.0.10/?some=parameter" }
|
72
74
|
before do
|
73
75
|
stub_request(:get, /^https:\/\/cas.example.org(:443)?\/serviceValidate\?([^&]+&)?ticket=593af/).
|
74
76
|
with { |request| @request_uri = request.uri.to_s }.
|
75
77
|
to_return( :body => File.read('spec/fixtures/cas_success.xml') )
|
76
|
-
|
78
|
+
|
79
|
+
get "/auth/cas/callback?ticket=593af&url=#{return_url}"
|
77
80
|
end
|
78
81
|
|
79
82
|
it 'should strip the ticket parameter from the callback URL' do
|
80
83
|
@request_uri.scan('ticket=').length.should == 1
|
81
84
|
end
|
82
85
|
|
86
|
+
it "should properly encode the service URL" do
|
87
|
+
WebMock.should have_requested(:get, "https://cas.example.org/serviceValidate")
|
88
|
+
.with(:query => {
|
89
|
+
:ticket => "593af",
|
90
|
+
:service => "http://example.org/auth/cas/callback?url=" + Rack::Utils.escape("http://127.0.0.10/?some=parameter")
|
91
|
+
})
|
92
|
+
end
|
93
|
+
|
83
94
|
context "request.env['omniauth.auth']" do
|
84
95
|
subject { last_request.env['omniauth.auth'] }
|
85
96
|
it { should be_kind_of Hash }
|
data/spec/spec_helper.rb
CHANGED
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.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-01-
|
12
|
+
date: 2012-01-24 00:00:00.000000000Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth
|
16
|
-
requirement: &
|
16
|
+
requirement: &2156820900 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 1.0.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2156820900
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: nokogiri
|
27
|
-
requirement: &
|
27
|
+
requirement: &2156820400 !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: *2156820400
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: addressable
|
38
|
-
requirement: &
|
38
|
+
requirement: &2156819940 !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: *2156819940
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rake
|
49
|
-
requirement: &
|
49
|
+
requirement: &2156819480 !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: *2156819480
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: webmock
|
60
|
-
requirement: &
|
60
|
+
requirement: &2156819020 !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: *2156819020
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
|
-
requirement: &
|
71
|
+
requirement: &2156818560 !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: *2156818560
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: rspec
|
82
|
-
requirement: &
|
82
|
+
requirement: &2156818100 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ~>
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '2.8'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *2156818100
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: rack-test
|
93
|
-
requirement: &
|
93
|
+
requirement: &2156817580 !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: *2156817580
|
102
102
|
- !ruby/object:Gem::Dependency
|
103
103
|
name: awesome_print
|
104
|
-
requirement: &
|
104
|
+
requirement: &2156817160 !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: *2156817160
|
113
113
|
description:
|
114
114
|
email:
|
115
115
|
- dlindahl@customink.com
|