omniauth-tequila 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +21 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +66 -0
- data/Rakefile +15 -0
- data/lib/omniauth-tequila.rb +1 -0
- data/lib/omniauth/strategies/tequila.rb +133 -0
- data/lib/omniauth/tequila.rb +2 -0
- data/lib/omniauth/tequila/version.rb +5 -0
- data/omniauth-tequila.gemspec +32 -0
- data/spec/fixtures/tequila_fetchattributes_bad.txt +16 -0
- data/spec/fixtures/tequila_fetchattributes_good.txt +17 -0
- data/spec/omniauth/strategies/tequila_spec.rb +173 -0
- data/spec/spec_helper.rb +17 -0
- metadata +176 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 797ef0c0588e7641e6e7f560cc6c6bbaf6115137
|
4
|
+
data.tar.gz: 5b0cc0b40fa477eb10ba8a2dffcc37b51a40ba63
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5d82cc5a59e88cfc4f31b11b34817c32e686a6fdb59fca5be80c7504d3c464f1979e233b5ed9630218dc3aed13fba6402f2758436ab88d01f462c3ee7ff80859
|
7
|
+
data.tar.gz: b1e2abf599ca023eb34e7e8d4d07ad0f300d7b50b8467d49ea81cc97b1ee45aa447614eebd7b2f720d0dfe9a12629ab415271cdbb2cdaf666f679835e989e650
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Chris Bird
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# OmniAuth Tequila Strategy [![Gem Version][version_badge]][version] [![Build Status][travis_status]][travis]
|
2
|
+
|
3
|
+
[version_badge]: https://badge.fury.io/rb/omniauth-tequila.png
|
4
|
+
[version]: http://badge.fury.io/rb/omniauth-tequila
|
5
|
+
[travis]: http://travis-ci.org/twowordbird/omniauth-tequila
|
6
|
+
[travis_status]: https://secure.travis-ci.org/twowordbird/omniauth-tequila.png
|
7
|
+
|
8
|
+
This is an OmniAuth 1.0 compatible strategy that authenticates via EPFL's [Tequila][tequila] protocol, structured after [omniauth-cas][omniauth_cas]. By default, it connects to EPFL's Tequila server, but it is fully configurable.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
gem 'omniauth-tequila'
|
15
|
+
|
16
|
+
And then execute:
|
17
|
+
|
18
|
+
$ bundle
|
19
|
+
|
20
|
+
Or install it yourself as:
|
21
|
+
|
22
|
+
$ gem install omniauth-tequila
|
23
|
+
|
24
|
+
## Usage
|
25
|
+
|
26
|
+
Use like any other OmniAuth strategy:
|
27
|
+
|
28
|
+
```ruby
|
29
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
30
|
+
provider :tequila #, :option => value, ...
|
31
|
+
end
|
32
|
+
```
|
33
|
+
|
34
|
+
### Configuration Options
|
35
|
+
|
36
|
+
OmniAuth Tequila authenticates with the EPFL server over SSL by default. However, it supports the following configuration options:
|
37
|
+
|
38
|
+
* `host` - Defines the host of your Tequila server
|
39
|
+
* `path` - Defines the URL relative to the host that the application sits behind
|
40
|
+
* `port` - The port to use for your configured Tequila `host`
|
41
|
+
* `ssl` - true to connect to your Tequila server over SSL
|
42
|
+
* `disable_ssl_verification` - Optional when `ssl` is true. Disables verification.
|
43
|
+
* `ca_path` - Optional when `ssl` is `true`. Sets path of a CA certification directory. See [Net::HTTP][net_http] for more details
|
44
|
+
* `uid_field` - The user data attribute to use as your user's unique identifier. Defaults to `'uniqueid'` (which contains the user's SCIPER number when using EPFL's Tequila server)
|
45
|
+
* `request_info` - Hash that maps user attributes from Tequila to the [OmniAuth schema][omniauth_schema]. Defaults to `{ :name => 'displayname' }` (which is the user's full name when using EPFL's Tequila server)
|
46
|
+
|
47
|
+
If you encounter problems wih SSL certificates you may want to set the `ca_path` parameter or activate `disable_ssl_verification` (not recommended).
|
48
|
+
|
49
|
+
## Contributing
|
50
|
+
|
51
|
+
1. Fork it
|
52
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
53
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
54
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
55
|
+
5. Create new Pull Request
|
56
|
+
|
57
|
+
## Thanks
|
58
|
+
|
59
|
+
Special thanks go out to the following people
|
60
|
+
|
61
|
+
* Derek Lindahl (@dlindahl) and all the authors of [omniauth-cas][omniauth_cas]
|
62
|
+
|
63
|
+
[tequila]: http://tequila.epfl.ch/
|
64
|
+
[omniauth_cas]: http://github.com/dlindahl/omniauth-cas
|
65
|
+
[omniauth_schema]: https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
|
66
|
+
[net_http]: http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
require 'bundler/gem_tasks'
|
3
|
+
|
4
|
+
require 'rspec/core/rake_task'
|
5
|
+
desc 'Default: run specs.'
|
6
|
+
task default: :spec
|
7
|
+
|
8
|
+
desc 'Run specs'
|
9
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
10
|
+
t.rspec_opts = '--require spec_helper --color --order rand'
|
11
|
+
end
|
12
|
+
|
13
|
+
task :test do
|
14
|
+
fail %q{This application uses RSpec. Try running "rake spec"}
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
require "omniauth/tequila"
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'omniauth/strategy'
|
2
|
+
require 'addressable/uri'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Tequila
|
7
|
+
include OmniAuth::Strategy
|
8
|
+
|
9
|
+
class TequilaFail < StandardError; end
|
10
|
+
|
11
|
+
attr_accessor :raw_info
|
12
|
+
alias_method :user_info, :raw_info
|
13
|
+
|
14
|
+
option :name, :tequila # Required property by OmniAuth::Strategy
|
15
|
+
|
16
|
+
option :host, 'tequila.epfl.ch'
|
17
|
+
option :port, nil
|
18
|
+
option :path, '/cgi-bin/tequila'
|
19
|
+
option :ssl, true
|
20
|
+
option :uid_field, :uniqueid
|
21
|
+
option :request_info, { :name => 'displayname' }
|
22
|
+
|
23
|
+
# As required by https://github.com/intridea/omniauth/wiki/Auth-Hash-Schema
|
24
|
+
info do
|
25
|
+
Hash[ @options[:request_info].map {|k, v| [ k, raw_info[v] ] } ]
|
26
|
+
end
|
27
|
+
|
28
|
+
extra do
|
29
|
+
raw_info.reject {|k, v| k == @options[:uid_field].to_s or @options[:request_info].values.include?(k) }
|
30
|
+
end
|
31
|
+
|
32
|
+
uid do
|
33
|
+
raw_info[ @options[:uid_field].to_s ]
|
34
|
+
end
|
35
|
+
|
36
|
+
def callback_phase
|
37
|
+
response = fetch_attributes( request.params['key'] )
|
38
|
+
|
39
|
+
return fail!(:invalid_response, TequilaFail.new('nil response from Tequila')) if response.nil?
|
40
|
+
return fail!(:invalid_response, TequilaFail.new('Invalid reponse from Tequila: ' + response.code)) unless response.code == '200'
|
41
|
+
|
42
|
+
# parse attributes
|
43
|
+
self.raw_info = {}
|
44
|
+
response.body.each_line { |line|
|
45
|
+
item = line.split('=', 2)
|
46
|
+
if item.length == 2
|
47
|
+
raw_info[item[0]] = item[1].strip
|
48
|
+
end
|
49
|
+
}
|
50
|
+
|
51
|
+
missing_info = @options[:request_info].values.reject { |k| raw_info.include?(k) }
|
52
|
+
if !missing_info.empty?
|
53
|
+
log :error, 'Missing attributes in Tequila server response: ' + missing_info.join(', ')
|
54
|
+
return fail!(:invalid_info, TequilaFail.new('Invalid info from Tequila'))
|
55
|
+
end
|
56
|
+
|
57
|
+
super
|
58
|
+
end
|
59
|
+
|
60
|
+
def request_phase
|
61
|
+
response = get_request_key
|
62
|
+
if response.nil? or response.code != '200'
|
63
|
+
log :error, 'Received invalid response from Tequila server: ' + (response.nil? ? 'nil' : response.code)
|
64
|
+
return fail!(:invalid_response, TequilaFail.new('Invalid response from Tequila server'))
|
65
|
+
end
|
66
|
+
|
67
|
+
request_key = response.body[/^key=(.*)$/, 1]
|
68
|
+
if request_key.nil? or request_key.empty?
|
69
|
+
log :error, 'Received invalid key from Tequila server: ' + (request_key.nil? ? 'nil' : request_key)
|
70
|
+
return fail!(:invalid_key, TequilaFail.new('Invalid key from Tequila'))
|
71
|
+
end
|
72
|
+
|
73
|
+
# redirect to the Tequila server's login page
|
74
|
+
[
|
75
|
+
302,
|
76
|
+
{
|
77
|
+
'Location' => tequila_uri.to_s + '/requestauth?requestkey=' + request_key,
|
78
|
+
'Content-Type' => 'text/plain'
|
79
|
+
},
|
80
|
+
['You are being redirected to Tequila for sign-in.']
|
81
|
+
]
|
82
|
+
end
|
83
|
+
|
84
|
+
private
|
85
|
+
|
86
|
+
# retrieves user attributes from the Tequila server
|
87
|
+
def fetch_attributes( request_key )
|
88
|
+
tequila_post '/fetchattributes', "key=" + request_key
|
89
|
+
end
|
90
|
+
|
91
|
+
# retrieves the request key from the Tequila server
|
92
|
+
def get_request_key
|
93
|
+
# NB: You might want to set the service and required group yourself.
|
94
|
+
request_fields = @options[:request_info].values << @options[:uid_field]
|
95
|
+
body = 'urlaccess=' + callback_url + "\nservice=Omniauth\n" +
|
96
|
+
'request=' + request_fields.join(',') + "\nrequire=group=my-group"
|
97
|
+
tequila_post '/createrequest', body
|
98
|
+
end
|
99
|
+
|
100
|
+
# Build a Tequila host with protocol and port
|
101
|
+
#
|
102
|
+
#
|
103
|
+
def tequila_uri
|
104
|
+
@tequila_uri ||= begin
|
105
|
+
if @options.port.nil?
|
106
|
+
@options.port = @options.ssl ? 443 : 80
|
107
|
+
end
|
108
|
+
Addressable::URI.new(
|
109
|
+
:scheme => @options.ssl ? 'https' : 'http',
|
110
|
+
:host => @options.host,
|
111
|
+
:port => @options.port,
|
112
|
+
:path => @options.path
|
113
|
+
)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def tequila_post( path, body )
|
118
|
+
http = Net::HTTP.new(tequila_uri.host, tequila_uri.port)
|
119
|
+
http.use_ssl = @options.ssl
|
120
|
+
if http.use_ssl?
|
121
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_NONE if @options.disable_ssl_verification?
|
122
|
+
http.ca_path = @options.ca_path
|
123
|
+
end
|
124
|
+
response = nil
|
125
|
+
http.start do |c|
|
126
|
+
response = c.request_post tequila_uri.path + path, body
|
127
|
+
end
|
128
|
+
response
|
129
|
+
end
|
130
|
+
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/omniauth/tequila/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ['Chris Bird']
|
6
|
+
gem.email = ['chris@twowordbird.com']
|
7
|
+
gem.description = <<-EOF
|
8
|
+
This is an OmniAuth 1.0 compatible strategy that authenticates via EPFL's Tequila protocol. By default, it connects to EPFL's Tequila server, but it is fully configurable.
|
9
|
+
EOF
|
10
|
+
gem.summary = %q{Tequila Strategy for OmniAuth}
|
11
|
+
gem.homepage = 'https://github.com/twowordbird/omniauth-tequila'
|
12
|
+
gem.license = 'MIT'
|
13
|
+
|
14
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
15
|
+
gem.files = `git ls-files`.split("\n")
|
16
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
gem.name = 'omniauth-tequila'
|
18
|
+
gem.require_paths = ['lib']
|
19
|
+
gem.version = Omniauth::Tequila::VERSION
|
20
|
+
|
21
|
+
gem.add_dependency 'omniauth', '~> 1.1.0'
|
22
|
+
gem.add_dependency 'addressable', '~> 2.3'
|
23
|
+
|
24
|
+
gem.add_development_dependency 'rake', '~> 0.9'
|
25
|
+
gem.add_development_dependency 'webmock', '~> 1.8.11'
|
26
|
+
gem.add_development_dependency 'simplecov', '~> 0.7.1'
|
27
|
+
gem.add_development_dependency 'rspec', '~> 2.11'
|
28
|
+
gem.add_development_dependency 'rack-test', '~> 0.6'
|
29
|
+
|
30
|
+
gem.add_development_dependency 'awesome_print'
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
version=2.1.2
|
2
|
+
firstname=Chris
|
3
|
+
provider=
|
4
|
+
specrequire=group=my-group
|
5
|
+
status=ok
|
6
|
+
speckey=esu3r5e6fy0c616af80y5ienzrj2n6x8
|
7
|
+
email=chris@twowordbird.com
|
8
|
+
group=my-group
|
9
|
+
requesthost=128.128.128.128
|
10
|
+
authstrength=1
|
11
|
+
org=MYORG
|
12
|
+
specuid=999999
|
13
|
+
name=Bird
|
14
|
+
phone=+41 21 9999999
|
15
|
+
host=128.128.128.129
|
16
|
+
authorig=cookie
|
@@ -0,0 +1,17 @@
|
|
1
|
+
version=2.1.2
|
2
|
+
firstname=Chris
|
3
|
+
provider=
|
4
|
+
specrequire=group=my-group
|
5
|
+
status=ok
|
6
|
+
speckey=esu3r5e6fy0c616af80y5ienzrj2n6x8
|
7
|
+
email=chris@twowordbird.com
|
8
|
+
group=my-group
|
9
|
+
requesthost=128.128.128.128
|
10
|
+
authstrength=1
|
11
|
+
org=MYORG
|
12
|
+
specuid=999999
|
13
|
+
name=Bird
|
14
|
+
phone=+41 21 9999999
|
15
|
+
host=128.128.128.129
|
16
|
+
authorig=cookie
|
17
|
+
displayname=Chris Bird
|
@@ -0,0 +1,173 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Tequila, type: :strategy do
|
4
|
+
include Rack::Test::Methods
|
5
|
+
|
6
|
+
class MyTequilaProvider < OmniAuth::Strategies::Tequila; end # TODO: Not really needed. just an alias but it requires the :name option which might confuse users...
|
7
|
+
def app
|
8
|
+
Rack::Builder.new {
|
9
|
+
use OmniAuth::Test::PhonySession
|
10
|
+
use MyTequilaProvider, name: :tequila, host: 'tequila.example.org', path: '/application/path', ssl: false, port: 8080, uid_field: :specuid,
|
11
|
+
request_info: { :name => 'displayname', :first_name => 'firstname', :last_name => 'name', :email => 'email', :phone => 'phone' }
|
12
|
+
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
|
13
|
+
}.to_app
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'default options' do
|
17
|
+
subject { MyTequilaProvider.default_options.to_hash }
|
18
|
+
it 'points to the EPFL server over SSL' do
|
19
|
+
should include('ssl' => true)
|
20
|
+
should include('host' => 'tequila.epfl.ch')
|
21
|
+
should include('port' => nil)
|
22
|
+
should include('path' => '/cgi-bin/tequila')
|
23
|
+
should include('uid_field' => :uniqueid)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
describe 'GET /auth/tequila' do
|
28
|
+
# setup mock Tequila createrequest response
|
29
|
+
before(:each) do
|
30
|
+
stub_request(:post, 'http://tequila.example.org:8080/application/path/createrequest')
|
31
|
+
.with { |request| @request_body = request.body }
|
32
|
+
.to_return( status: response_code, body: response_body )
|
33
|
+
get '/auth/tequila'
|
34
|
+
end
|
35
|
+
|
36
|
+
shared_examples 'Tequila createrequest' do
|
37
|
+
describe 'createrequest body' do
|
38
|
+
subject { @request_body }
|
39
|
+
it { should match( /^urlaccess=http:\/\/example.org\/auth\/tequila\/callback$/ ) }
|
40
|
+
it { should match( /^service=Omniauth$/ ) }
|
41
|
+
|
42
|
+
describe 'requested attributes' do
|
43
|
+
subject { @request_body[/^request=(.*)$/, 1].scan( /(\w+)(,|$)/ ).collect(&:first) }
|
44
|
+
it { should have(6).items }
|
45
|
+
it { should include('specuid') }
|
46
|
+
it { should include('displayname') }
|
47
|
+
it { should include('email') }
|
48
|
+
it { should include('firstname') }
|
49
|
+
it { should include('name') }
|
50
|
+
it { should include('phone') }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when Tequila server works' do
|
56
|
+
let(:response_code) { 200 }
|
57
|
+
let(:response_body) { 'key=shkfe31zsy3ow7sgnfv2e2q164cbf1to' }
|
58
|
+
it_behaves_like 'Tequila createrequest'
|
59
|
+
|
60
|
+
subject { last_response }
|
61
|
+
it { should be_redirect }
|
62
|
+
it 'should redirect to the Tequila server' do
|
63
|
+
subject.headers['Location'].should == 'http://tequila.example.org:8080/application/path/requestauth?' +
|
64
|
+
'requestkey=shkfe31zsy3ow7sgnfv2e2q164cbf1to'
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when Tequila server returns a bad reponse code' do
|
69
|
+
let(:response_code) { 404 }
|
70
|
+
let(:response_body) { 'Page not found' }
|
71
|
+
it_behaves_like 'Tequila createrequest'
|
72
|
+
|
73
|
+
subject { last_response }
|
74
|
+
it { should be_redirect }
|
75
|
+
it 'should fail with invalid_response' do
|
76
|
+
subject.headers['Location'].should == '/auth/failure?message=invalid_response&strategy=tequila'
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when Tequila server returns a bad response body' do
|
81
|
+
let(:response_code) { 200 }
|
82
|
+
let(:response_body) { 'brokenkey=shkfe31zsy3ow7sgnfv2e2q164cbf1to' }
|
83
|
+
it_behaves_like 'Tequila createrequest'
|
84
|
+
|
85
|
+
subject { last_response }
|
86
|
+
it { should be_redirect }
|
87
|
+
it 'should fail with invalid_key' do
|
88
|
+
subject.headers['Location'].should == '/auth/failure?message=invalid_key&strategy=tequila'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
describe 'GET /auth/tequila/callback' do
|
94
|
+
# setup mock Tequila fetchattributes response
|
95
|
+
before(:each) do
|
96
|
+
stub_request(:post, 'http://tequila.example.org:8080/application/path/fetchattributes')
|
97
|
+
.with { |request| @request_body = request.body }
|
98
|
+
.to_return( status: response_code, body: response_body )
|
99
|
+
get '/auth/tequila/callback?key=esu3r5e6fy0c616af80y5ienzrj2n6x8'
|
100
|
+
end
|
101
|
+
|
102
|
+
shared_examples 'Tequila fetchattributes' do
|
103
|
+
describe 'fetchattributes body' do
|
104
|
+
subject { @request_body }
|
105
|
+
it { should match( /^key=esu3r5e6fy0c616af80y5ienzrj2n6x8$/ ) }
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
context 'when Tequila server works' do
|
110
|
+
let(:response_code) { 200 }
|
111
|
+
let(:response_body) { File.read('spec/fixtures/tequila_fetchattributes_good.txt') }
|
112
|
+
it_behaves_like 'Tequila fetchattributes'
|
113
|
+
|
114
|
+
describe 'omniauth.auth' do
|
115
|
+
subject { last_request.env['omniauth.auth'] }
|
116
|
+
it { should be_kind_of Hash }
|
117
|
+
its(:provider) { should == :tequila }
|
118
|
+
its(:uid) { should == '999999' }
|
119
|
+
end
|
120
|
+
|
121
|
+
describe 'omniauth.auth.info' do
|
122
|
+
subject { last_request.env['omniauth.auth']['info'] }
|
123
|
+
it { should have(5).items }
|
124
|
+
its(:name) { should == 'Chris Bird' }
|
125
|
+
its(:first_name) { should == 'Chris' }
|
126
|
+
its(:last_name) { should == 'Bird' }
|
127
|
+
its(:email) { should == 'chris@twowordbird.com' }
|
128
|
+
its(:phone) { should == '+41 21 9999999' }
|
129
|
+
end
|
130
|
+
|
131
|
+
describe 'omniauth.auth.extra' do
|
132
|
+
subject { last_request.env['omniauth.auth']['extra'] }
|
133
|
+
it { should have(11).items }
|
134
|
+
its(:version) { should == '2.1.2' }
|
135
|
+
its(:provider) { should == '' }
|
136
|
+
its(:specrequire) { should == 'group=my-group' }
|
137
|
+
its(:status) { should == 'ok' }
|
138
|
+
its(:speckey) { should == 'esu3r5e6fy0c616af80y5ienzrj2n6x8' }
|
139
|
+
its(:group) { should == 'my-group' }
|
140
|
+
its(:requesthost) { should == '128.128.128.128' }
|
141
|
+
its(:authstrength) { should == '1' }
|
142
|
+
its(:org) { should == 'MYORG' }
|
143
|
+
its(:host) { should == '128.128.128.129' }
|
144
|
+
its(:authorig) { should == 'cookie' }
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
context 'when Tequila server returns a bad response code' do
|
149
|
+
let(:response_code) { 404 }
|
150
|
+
let(:response_body) { 'Page not found' }
|
151
|
+
it_behaves_like 'Tequila fetchattributes'
|
152
|
+
|
153
|
+
subject { last_response }
|
154
|
+
it { should be_redirect }
|
155
|
+
it 'should fail with invalid_response' do
|
156
|
+
subject.headers['Location'].should == '/auth/failure?message=invalid_response&strategy=tequila'
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
context 'when Tequila server returns bad info' do
|
161
|
+
let(:response_code) { 200 }
|
162
|
+
let(:response_body) { File.read('spec/fixtures/tequila_fetchattributes_bad.txt') }
|
163
|
+
it_behaves_like 'Tequila fetchattributes'
|
164
|
+
|
165
|
+
subject { last_response }
|
166
|
+
it { should be_redirect }
|
167
|
+
it 'should fail with invalid_info' do
|
168
|
+
subject.headers['Location'].should == '/auth/failure?message=invalid_info&strategy=tequila'
|
169
|
+
end
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require 'awesome_print'
|
3
|
+
|
4
|
+
RSpec.configure do |c|
|
5
|
+
c.filter_run focus: true
|
6
|
+
c.run_all_when_everything_filtered = true
|
7
|
+
c.treat_symbols_as_metadata_keys_with_true_values = true
|
8
|
+
end
|
9
|
+
|
10
|
+
require 'simplecov'
|
11
|
+
SimpleCov.start
|
12
|
+
|
13
|
+
require 'rack/test'
|
14
|
+
require 'webmock/rspec'
|
15
|
+
require 'omniauth-tequila'
|
16
|
+
|
17
|
+
OmniAuth.config.logger = Logger.new( '/dev/null' )
|
metadata
ADDED
@@ -0,0 +1,176 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-tequila
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.3
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Chris Bird
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-04-06 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: omniauth
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 1.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 1.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: addressable
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ~>
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0.9'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ~>
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0.9'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: webmock
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.8.11
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.8.11
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ~>
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.7.1
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ~>
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.7.1
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rspec
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.11'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.11'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rack-test
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0.6'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0.6'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: awesome_print
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - '>='
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - '>='
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
description: |2
|
126
|
+
This is an OmniAuth 1.0 compatible strategy that authenticates via EPFL's Tequila protocol. By default, it connects to EPFL's Tequila server, but it is fully configurable.
|
127
|
+
email:
|
128
|
+
- chris@twowordbird.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- .gitignore
|
134
|
+
- .travis.yml
|
135
|
+
- Gemfile
|
136
|
+
- LICENSE
|
137
|
+
- README.md
|
138
|
+
- Rakefile
|
139
|
+
- lib/omniauth-tequila.rb
|
140
|
+
- lib/omniauth/strategies/tequila.rb
|
141
|
+
- lib/omniauth/tequila.rb
|
142
|
+
- lib/omniauth/tequila/version.rb
|
143
|
+
- omniauth-tequila.gemspec
|
144
|
+
- spec/fixtures/tequila_fetchattributes_bad.txt
|
145
|
+
- spec/fixtures/tequila_fetchattributes_good.txt
|
146
|
+
- spec/omniauth/strategies/tequila_spec.rb
|
147
|
+
- spec/spec_helper.rb
|
148
|
+
homepage: https://github.com/twowordbird/omniauth-tequila
|
149
|
+
licenses:
|
150
|
+
- MIT
|
151
|
+
metadata: {}
|
152
|
+
post_install_message:
|
153
|
+
rdoc_options: []
|
154
|
+
require_paths:
|
155
|
+
- lib
|
156
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
157
|
+
requirements:
|
158
|
+
- - '>='
|
159
|
+
- !ruby/object:Gem::Version
|
160
|
+
version: '0'
|
161
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - '>='
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
requirements: []
|
167
|
+
rubyforge_project:
|
168
|
+
rubygems_version: 2.1.11
|
169
|
+
signing_key:
|
170
|
+
specification_version: 4
|
171
|
+
summary: Tequila Strategy for OmniAuth
|
172
|
+
test_files:
|
173
|
+
- spec/fixtures/tequila_fetchattributes_bad.txt
|
174
|
+
- spec/fixtures/tequila_fetchattributes_good.txt
|
175
|
+
- spec/omniauth/strategies/tequila_spec.rb
|
176
|
+
- spec/spec_helper.rb
|