omniauth-vph 1.0.0
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 +7 -0
- data/.gitignore +16 -0
- data/.rspec +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +4 -0
- data/Gemfile.lock +83 -0
- data/Guardfile +11 -0
- data/LICENSE.txt +22 -0
- data/README.md +50 -0
- data/Rakefile +9 -0
- data/lib/omniauth-vph.rb +3 -0
- data/lib/omniauth-vph/adaptor.rb +63 -0
- data/lib/omniauth-vph/version.rb +5 -0
- data/lib/omniauth/strategies/vphticket.rb +54 -0
- data/omniauth-vph.gemspec +30 -0
- data/spec/omniauth-vph/adaptor_spec.rb +73 -0
- data/spec/omniauth/strategies/vphticket_spec.rb +118 -0
- data/spec/spec_helper.rb +15 -0
- metadata +204 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 3d9ff167565aa2c7162c211f24320e71003d6add
|
4
|
+
data.tar.gz: 4f14f66558f86a57e4f36474f872087bd92a654c
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 9672350bc14934b6f73ac5b46eeed63c28d5619957ba76f1d3af00a00b15ce68ddfa759be3e9aa92b72b3a40f42cf469d9e693c31c0da98a56c1ea742072b90d
|
7
|
+
data.tar.gz: 84cb67bc00f6ae61c090ca6fcaca2e86dcefe5f276531edadf67790cdf415b9e449e6f45626d3fa7abebb0cbcfb0e2fb79736df85d49b4ebe74fdd7909c30e00
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.0.0-p247
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,83 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-vph (1.0.0)
|
5
|
+
faraday
|
6
|
+
multi_json
|
7
|
+
omniauth (~> 1.0)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
celluloid (0.15.2)
|
13
|
+
timers (~> 1.1.0)
|
14
|
+
celluloid-io (0.15.0)
|
15
|
+
celluloid (>= 0.15.0)
|
16
|
+
nio4r (>= 0.5.0)
|
17
|
+
coderay (1.1.0)
|
18
|
+
diff-lcs (1.2.5)
|
19
|
+
faraday (0.9.0)
|
20
|
+
multipart-post (>= 1.2, < 3)
|
21
|
+
ffi (1.9.3)
|
22
|
+
formatador (0.2.4)
|
23
|
+
guard (2.5.1)
|
24
|
+
formatador (>= 0.2.4)
|
25
|
+
listen (~> 2.6)
|
26
|
+
lumberjack (~> 1.0)
|
27
|
+
pry (>= 0.9.12)
|
28
|
+
thor (>= 0.18.1)
|
29
|
+
guard-bundler (2.0.0)
|
30
|
+
bundler (~> 1.0)
|
31
|
+
guard (~> 2.2)
|
32
|
+
guard-rspec (4.2.8)
|
33
|
+
guard (~> 2.1)
|
34
|
+
rspec (>= 2.14, < 4.0)
|
35
|
+
hashie (2.0.5)
|
36
|
+
listen (2.7.0)
|
37
|
+
celluloid (>= 0.15.2)
|
38
|
+
celluloid-io (>= 0.15.0)
|
39
|
+
rb-fsevent (>= 0.9.3)
|
40
|
+
rb-inotify (>= 0.9)
|
41
|
+
lumberjack (1.0.4)
|
42
|
+
method_source (0.8.2)
|
43
|
+
multi_json (1.9.0)
|
44
|
+
multipart-post (2.0.0)
|
45
|
+
nio4r (1.0.0)
|
46
|
+
omniauth (1.2.1)
|
47
|
+
hashie (>= 1.2, < 3)
|
48
|
+
rack (~> 1.0)
|
49
|
+
pry (0.9.12.6)
|
50
|
+
coderay (~> 1.0)
|
51
|
+
method_source (~> 0.8)
|
52
|
+
slop (~> 3.4)
|
53
|
+
rack (1.5.2)
|
54
|
+
rack-test (0.6.2)
|
55
|
+
rack (>= 1.0)
|
56
|
+
rake (10.1.1)
|
57
|
+
rb-fsevent (0.9.4)
|
58
|
+
rb-inotify (0.9.3)
|
59
|
+
ffi (>= 0.5.0)
|
60
|
+
rspec (2.14.1)
|
61
|
+
rspec-core (~> 2.14.0)
|
62
|
+
rspec-expectations (~> 2.14.0)
|
63
|
+
rspec-mocks (~> 2.14.0)
|
64
|
+
rspec-core (2.14.8)
|
65
|
+
rspec-expectations (2.14.5)
|
66
|
+
diff-lcs (>= 1.1.3, < 2.0)
|
67
|
+
rspec-mocks (2.14.6)
|
68
|
+
slop (3.5.0)
|
69
|
+
thor (0.18.1)
|
70
|
+
timers (1.1.0)
|
71
|
+
|
72
|
+
PLATFORMS
|
73
|
+
ruby
|
74
|
+
|
75
|
+
DEPENDENCIES
|
76
|
+
bundler
|
77
|
+
guard
|
78
|
+
guard-bundler
|
79
|
+
guard-rspec
|
80
|
+
omniauth-vph!
|
81
|
+
rack-test
|
82
|
+
rake
|
83
|
+
rspec
|
data/Guardfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Marek Kasztelnik
|
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,50 @@
|
|
1
|
+
# Omniauth Vph
|
2
|
+
|
3
|
+
Use the VPH-Share ticket strategy as a middleware in your application:
|
4
|
+
|
5
|
+
```ruby
|
6
|
+
use OmniAuth::Strategies::Vphticket,
|
7
|
+
host: 'https://portal.vph-share.eu',
|
8
|
+
roles_map: {cloudadmin: 'admin', developer: 'developer'}
|
9
|
+
ssl_verify: true #or false if self signed cert is used
|
10
|
+
```
|
11
|
+
|
12
|
+
VPH-Share Ticket is required to use this strategy. It can be retrieved after successful log in into Master Interface, located in `host` URL.
|
13
|
+
|
14
|
+
VPH-Share security mechanism is role based. `roles_map` allows to map VPH-Share
|
15
|
+
roles into application specific roles.
|
16
|
+
|
17
|
+
`ssl_verify` true/false flag is used to turn on or off ssl validation by Faraday client, while trigering ticket validation request.
|
18
|
+
|
19
|
+
The result of invoking this strategy is a object with following elements:
|
20
|
+
|
21
|
+
```
|
22
|
+
login
|
23
|
+
email
|
24
|
+
full_name
|
25
|
+
roles
|
26
|
+
```
|
27
|
+
|
28
|
+
inside `roles` array application specific roles are returned based on `roles_map` hash.
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
|
32
|
+
Add this line to your application's Gemfile:
|
33
|
+
|
34
|
+
gem 'omniauth-vph'
|
35
|
+
|
36
|
+
And then execute:
|
37
|
+
|
38
|
+
$ bundle
|
39
|
+
|
40
|
+
Or install it yourself as:
|
41
|
+
|
42
|
+
$ gem install omniauth-vph
|
43
|
+
|
44
|
+
## Contributing
|
45
|
+
|
46
|
+
1. Fork it
|
47
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
48
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/lib/omniauth-vph.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'faraday'
|
2
|
+
require 'json'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Vph
|
6
|
+
class Adaptor
|
7
|
+
class ConnectionError < StandardError; end
|
8
|
+
|
9
|
+
MUST_HAVE_KEYS = [:host]
|
10
|
+
|
11
|
+
attr_reader :connection
|
12
|
+
|
13
|
+
def self.validate(configuration={})
|
14
|
+
message = []
|
15
|
+
MUST_HAVE_KEYS.each do |name|
|
16
|
+
message << name if configuration[name].nil?
|
17
|
+
end
|
18
|
+
raise ArgumentError.new(message.join(",") +" MUST be provided") unless message.empty?
|
19
|
+
end
|
20
|
+
|
21
|
+
def initialize(configuration={})
|
22
|
+
Adaptor.validate(configuration)
|
23
|
+
@configuration = configuration.dup
|
24
|
+
|
25
|
+
verify = @configuration[:ssl_verify] == nil ? true : @configuration[:ssl_verify]
|
26
|
+
@connection = Faraday.new(url: @configuration[:host], :ssl => {:verify => verify})
|
27
|
+
end
|
28
|
+
|
29
|
+
def user_info(ticket)
|
30
|
+
begin
|
31
|
+
response = @connection.get '/validatetkt/', {ticket: ticket}
|
32
|
+
response.status == 200 ? JSON.parse(response.body) : nil
|
33
|
+
rescue Exception => e
|
34
|
+
raise ConnectionError.new
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def map_user(object)
|
39
|
+
user = {}
|
40
|
+
user['email'] = object['email']
|
41
|
+
user['login'] = object['username']
|
42
|
+
user['full_name'] = object['fullname']
|
43
|
+
user['roles'] = roles object
|
44
|
+
|
45
|
+
user
|
46
|
+
end
|
47
|
+
|
48
|
+
private
|
49
|
+
|
50
|
+
def roles(object)
|
51
|
+
roles_map = @configuration[:roles_map]
|
52
|
+
roles = []
|
53
|
+
if object['role'] and roles_map
|
54
|
+
roles_map.each do |k,v|
|
55
|
+
roles << v if object['role'].include? k
|
56
|
+
end
|
57
|
+
end
|
58
|
+
roles
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'multi_json'
|
2
|
+
require 'omniauth'
|
3
|
+
|
4
|
+
module OmniAuth
|
5
|
+
module Strategies
|
6
|
+
class Vphticket
|
7
|
+
include OmniAuth::Strategy
|
8
|
+
|
9
|
+
option :title, 'VPH-Share Master Interface Ticket Authentication' #default title for authentication form
|
10
|
+
option :host
|
11
|
+
|
12
|
+
option :roles_map
|
13
|
+
|
14
|
+
def request_phase
|
15
|
+
OmniAuth::Vph::Adaptor.validate @options
|
16
|
+
f = OmniAuth::Form.new(:title => (options[:title] || 'VPH-Share Master Interface Ticket Authentication'), :url => callback_path)
|
17
|
+
f.password_field 'Ticket', 'ticket'
|
18
|
+
f.button "Sign In"
|
19
|
+
f.to_response
|
20
|
+
end
|
21
|
+
|
22
|
+
def callback_phase
|
23
|
+
@adaptor = OmniAuth::Vph::Adaptor.new @options
|
24
|
+
|
25
|
+
return fail!(:missing_credentials) if missing_credentials?
|
26
|
+
begin
|
27
|
+
@mi_user_info = @adaptor.user_info request['ticket']
|
28
|
+
return fail!(:invalid_credentials) if !@mi_user_info
|
29
|
+
|
30
|
+
@user_info = @adaptor.map_user(@mi_user_info)
|
31
|
+
super
|
32
|
+
rescue Exception => e
|
33
|
+
return fail!(:master_interface_error, e)
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
uid {
|
38
|
+
@user_info["login"]
|
39
|
+
}
|
40
|
+
|
41
|
+
info {
|
42
|
+
@user_info
|
43
|
+
}
|
44
|
+
|
45
|
+
extra {
|
46
|
+
{ :raw_info => @mi_user_info }
|
47
|
+
}
|
48
|
+
|
49
|
+
def missing_credentials?
|
50
|
+
request['ticket'].nil? or request['ticket'].empty?
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-vph/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "omniauth-vph"
|
8
|
+
spec.version = Omniauth::Vph::VERSION
|
9
|
+
spec.authors = ["Marek Kasztelnik"]
|
10
|
+
spec.email = ["mkasztelnik@gmail.com"]
|
11
|
+
spec.description = %q{A VPH-Share Master Interface strategy for OmniAuth.}
|
12
|
+
spec.summary = %q{A VPH-Share Master Interface strategy for OmniAuth.}
|
13
|
+
spec.homepage = "https://gitlab.dev.cyfronet.pl/atmosphere/omniauth-vph"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files`.split($/)
|
17
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
18
|
+
spec.require_paths = ["lib"]
|
19
|
+
|
20
|
+
spec.add_runtime_dependency 'omniauth', '~> 1.0'
|
21
|
+
spec.add_runtime_dependency 'multi_json'
|
22
|
+
spec.add_runtime_dependency 'faraday'
|
23
|
+
spec.add_development_dependency 'rspec'
|
24
|
+
spec.add_development_dependency "bundler"
|
25
|
+
spec.add_development_dependency "rake"
|
26
|
+
spec.add_development_dependency 'rack-test'
|
27
|
+
spec.add_development_dependency 'guard'
|
28
|
+
spec.add_development_dependency 'guard-rspec'
|
29
|
+
spec.add_development_dependency 'guard-bundler'
|
30
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Vph::Adaptor do
|
4
|
+
let(:adaptor) { OmniAuth::Vph::Adaptor.new({host: 'http://validatetkt.host', roles_map: { 'cloudadmin' => 'admin', 'Developer' => 'developer' }}) }
|
5
|
+
|
6
|
+
describe '#initialize' do
|
7
|
+
it 'should throw exception when must have field is not set' do
|
8
|
+
expect {
|
9
|
+
#[:host]
|
10
|
+
OmniAuth::Vph::Adaptor.new({})
|
11
|
+
}.to raise_error(ArgumentError)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#user_info' do
|
16
|
+
before(:each) do
|
17
|
+
@faraday = double(Faraday)
|
18
|
+
Faraday.stub(:new).and_return(@faraday)
|
19
|
+
|
20
|
+
allow(@faraday).to receive(:get).with('/validatetkt/', {ticket: 'correct_ticket'}).and_return(faraday_response(200, '{"user": "details"}'))
|
21
|
+
|
22
|
+
allow(@faraday).to receive(:get).with('/validatetkt/', {ticket: 'wrong_ticket'}).and_return(faraday_response 403)
|
23
|
+
|
24
|
+
allow(@faraday).to receive(:get).with('/validatetkt/', {ticket: 'wrong_host'}).and_raise(Exception.new)
|
25
|
+
|
26
|
+
adaptor = OmniAuth::Vph::Adaptor.new({host: 'http://validatetkt.host'})
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'returns nil when user ticket is not valid' do
|
30
|
+
expect(adaptor.user_info('wrong_ticket')).to be_nil
|
31
|
+
end
|
32
|
+
|
33
|
+
it 'returns user infor when ticket is valid' do
|
34
|
+
expect(adaptor.user_info('correct_ticket')).to eq({"user" => "details"})
|
35
|
+
end
|
36
|
+
|
37
|
+
it 'throws ConnectionError when unable to connect to the service' do
|
38
|
+
expect {
|
39
|
+
adaptor.user_info('wrong_host')
|
40
|
+
}.to raise_error(OmniAuth::Vph::Adaptor::ConnectionError)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#map_user' do
|
45
|
+
let(:info) do
|
46
|
+
{
|
47
|
+
"username" => "foobar",
|
48
|
+
"language" => "",
|
49
|
+
"country"=> "POLAND",
|
50
|
+
"role" => [ "Developer", "admin", "cloudadmin", "vph" ],
|
51
|
+
"postcode" => "30950",
|
52
|
+
"fullname" => "Foo Bar",
|
53
|
+
"email" => "foobar@gmail.pl"
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
it 'returns user info' do
|
58
|
+
user_map = adaptor.map_user info
|
59
|
+
|
60
|
+
expect(user_map['email']).to eq 'foobar@gmail.pl'
|
61
|
+
expect(user_map['login']).to eq 'foobar'
|
62
|
+
expect(user_map['full_name']).to eq 'Foo Bar'
|
63
|
+
expect(user_map['roles']).to eq ['admin', 'developer']
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def faraday_response(status, body=nil)
|
68
|
+
response = double Faraday::Response
|
69
|
+
allow(response).to receive(:status).and_return status
|
70
|
+
allow(response).to receive(:body).and_return body
|
71
|
+
response
|
72
|
+
end
|
73
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe OmniAuth::Strategies::Vphticket do
|
4
|
+
|
5
|
+
class VphticketProvider < OmniAuth::Strategies::Vphticket; end
|
6
|
+
|
7
|
+
let(:app) do
|
8
|
+
Rack::Builder.new {
|
9
|
+
use OmniAuth::Test::PhonySession
|
10
|
+
use VphticketProvider, name: 'vph', title: 'MI Form', host: 'http://mi.host'
|
11
|
+
run lambda { |env| [404, {'Content-Type' => 'text/plain'}, [env.key?('omniauth.auth').to_s]] }
|
12
|
+
}.to_app
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:session) do
|
16
|
+
last_request.env['rack.session']
|
17
|
+
end
|
18
|
+
|
19
|
+
describe '/auth/vph' do
|
20
|
+
before(:each){ get '/auth/vph' }
|
21
|
+
|
22
|
+
it 'displays a form' do
|
23
|
+
last_response.status.should == 200
|
24
|
+
last_response.body.should be_include("<form")
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'has the callback as the action for the form' do
|
28
|
+
last_response.body.should be_include("action='/auth/vph/callback'")
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'should have a text field' do
|
32
|
+
last_response.body.scan('<input').size.should == 1
|
33
|
+
end
|
34
|
+
it 'has a label of the form title' do
|
35
|
+
last_response.body.scan('MI Form').size.should > 1
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe 'post /auth/vph/callback' do
|
40
|
+
before(:each) do
|
41
|
+
@adaptor = double(OmniAuth::Vph::Adaptor)
|
42
|
+
OmniAuth::Vph::Adaptor.stub(:new).and_return(@adaptor)
|
43
|
+
end
|
44
|
+
|
45
|
+
context 'success' do
|
46
|
+
let(:auth_hash){ last_request.env['omniauth.auth'] }
|
47
|
+
before(:each) do
|
48
|
+
info = {
|
49
|
+
"username" => "foobar",
|
50
|
+
"language" => "",
|
51
|
+
"country"=> "POLAND",
|
52
|
+
"role" => [ "Developer", "admin", "cloudadmin", "vph" ],
|
53
|
+
"postcode" => "30950",
|
54
|
+
"fullname" => "Foo Bar",
|
55
|
+
"email" => "foobar@gmail.pl"
|
56
|
+
}
|
57
|
+
|
58
|
+
allow(@adaptor).to receive(:user_info).with('ticket_payload').and_return(info)
|
59
|
+
|
60
|
+
allow(@adaptor).to receive(:map_user).with(info).and_return({
|
61
|
+
'email' => info['email'],
|
62
|
+
'login' => info['username'],
|
63
|
+
'full_name' => info['fullname'],
|
64
|
+
'roles' => ['admin', 'developer']
|
65
|
+
})
|
66
|
+
|
67
|
+
post('/auth/vph/callback', {ticket: 'ticket_payload'})
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'should not redirect to error page' do
|
71
|
+
last_response.should_not be_redirect
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should map user info to Auth Hash' do
|
75
|
+
expect(auth_hash.uid).to eq 'foobar'
|
76
|
+
expect(auth_hash.info.email).to eq 'foobar@gmail.pl'
|
77
|
+
expect(auth_hash.info.login).to eq 'foobar'
|
78
|
+
expect(auth_hash.info.full_name).to eq 'Foo Bar'
|
79
|
+
expect(auth_hash.info.roles).to eq ['admin', 'developer']
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'failure' do
|
84
|
+
before(:each) do
|
85
|
+
allow(@adaptor).to receive(:user_info).and_return(false)
|
86
|
+
end
|
87
|
+
|
88
|
+
context 'when ticket is not present' do
|
89
|
+
it 'redirects to error page' do
|
90
|
+
post('/auth/vph/callback', {})
|
91
|
+
|
92
|
+
last_response.should be_redirect
|
93
|
+
last_response.headers['Location'].should =~ %r{missing_credentials}
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
context "when ticket is empty" do
|
98
|
+
it 'redirects to error page' do
|
99
|
+
post('/auth/vph/callback', {ticket: ""})
|
100
|
+
|
101
|
+
last_response.should be_redirect
|
102
|
+
last_response.headers['Location'].should =~ %r{missing_credentials}
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context "when username and password are present" do
|
107
|
+
context "and bind on master interface server failed" do
|
108
|
+
it 'redirects to error page' do
|
109
|
+
post('/auth/vph/callback', {ticket: 'ticket_payload'})
|
110
|
+
|
111
|
+
last_response.should be_redirect
|
112
|
+
last_response.headers['Location'].should =~ %r{invalid_credentials}
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
require 'rspec'
|
4
|
+
require 'rack/test'
|
5
|
+
require 'omniauth'
|
6
|
+
require 'omniauth-vph'
|
7
|
+
|
8
|
+
RSpec.configure do |config|
|
9
|
+
config.include Rack::Test::Methods
|
10
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
11
|
+
|
12
|
+
#http://stackoverflow.com/a/7853245/1535165
|
13
|
+
config.filter_run :focus => true
|
14
|
+
config.run_all_when_everything_filtered = true
|
15
|
+
end
|
metadata
ADDED
@@ -0,0 +1,204 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-vph
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Marek Kasztelnik
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-13 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.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.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: multi_json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: faraday
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rspec
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: bundler
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rake
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
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'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: guard
|
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
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: guard-rspec
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - '>='
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - '>='
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: guard-bundler
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - '>='
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - '>='
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
description: A VPH-Share Master Interface strategy for OmniAuth.
|
154
|
+
email:
|
155
|
+
- mkasztelnik@gmail.com
|
156
|
+
executables: []
|
157
|
+
extensions: []
|
158
|
+
extra_rdoc_files: []
|
159
|
+
files:
|
160
|
+
- .gitignore
|
161
|
+
- .rspec
|
162
|
+
- .ruby-version
|
163
|
+
- Gemfile
|
164
|
+
- Gemfile.lock
|
165
|
+
- Guardfile
|
166
|
+
- LICENSE.txt
|
167
|
+
- README.md
|
168
|
+
- Rakefile
|
169
|
+
- lib/omniauth-vph.rb
|
170
|
+
- lib/omniauth-vph/adaptor.rb
|
171
|
+
- lib/omniauth-vph/version.rb
|
172
|
+
- lib/omniauth/strategies/vphticket.rb
|
173
|
+
- omniauth-vph.gemspec
|
174
|
+
- spec/omniauth-vph/adaptor_spec.rb
|
175
|
+
- spec/omniauth/strategies/vphticket_spec.rb
|
176
|
+
- spec/spec_helper.rb
|
177
|
+
homepage: https://gitlab.dev.cyfronet.pl/atmosphere/omniauth-vph
|
178
|
+
licenses:
|
179
|
+
- MIT
|
180
|
+
metadata: {}
|
181
|
+
post_install_message:
|
182
|
+
rdoc_options: []
|
183
|
+
require_paths:
|
184
|
+
- lib
|
185
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
186
|
+
requirements:
|
187
|
+
- - '>='
|
188
|
+
- !ruby/object:Gem::Version
|
189
|
+
version: '0'
|
190
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - '>='
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
requirements: []
|
196
|
+
rubyforge_project:
|
197
|
+
rubygems_version: 2.1.10
|
198
|
+
signing_key:
|
199
|
+
specification_version: 4
|
200
|
+
summary: A VPH-Share Master Interface strategy for OmniAuth.
|
201
|
+
test_files:
|
202
|
+
- spec/omniauth-vph/adaptor_spec.rb
|
203
|
+
- spec/omniauth/strategies/vphticket_spec.rb
|
204
|
+
- spec/spec_helper.rb
|