omniauth-homeaway 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +18 -0
- data/.rspec +1 -0
- data/.rubocop.yml +7 -0
- data/.rubocop_todo.yml +19 -0
- data/.travis.yml +8 -0
- data/CHANGELOG.md +5 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +70 -0
- data/README.md +50 -0
- data/Rakefile +7 -0
- data/example/.powenv.sample +2 -0
- data/example/Gemfile +3 -0
- data/example/Gemfile.lock +48 -0
- data/example/ReadMe.md +45 -0
- data/example/config.ru +7 -0
- data/example/homeaway_oauth_helper.rb +53 -0
- data/lib/omniauth-homeaway.rb +2 -0
- data/lib/omniauth/homeaway/version.rb +5 -0
- data/lib/omniauth/strategies/homeaway.rb +35 -0
- data/omniauth-homeaway.gemspec +26 -0
- data/spec/omniauth/strategies/homeaway_spec.rb +83 -0
- data/spec/spec_helper.rb +6 -0
- data/spec/support/shared_examples.rb +59 -0
- metadata +140 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c94791c31ef20128794c3c1be75e1cbddf3b5ba5
|
4
|
+
data.tar.gz: 4a79cca7adc9356eed7a8fc2623e606aacde2b36
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 05a3388db1f5621dda30800561d90e82da47313ec4cffb84539b8d520ea35dd740eba98d42d23038bf1a9c92fa0078ba52bf867abab474688848057024736068
|
7
|
+
data.tar.gz: 35878b2ca573ad05514c212acd8a3ca2d2f01fad54266976776d2fcaf1ce39b70808c03229a2f1ee848aae69add24aace66d32d45c9b72c3e173607d58db696e
|
data/.gitignore
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour
|
data/.rubocop.yml
ADDED
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2015-10-28 12:37:10 +0100 using RuboCop version 0.34.1.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 2
|
10
|
+
Style/Documentation:
|
11
|
+
Exclude:
|
12
|
+
- 'lib/omniauth/homeaway/version.rb'
|
13
|
+
- 'lib/omniauth/strategies/homeaway.rb'
|
14
|
+
|
15
|
+
# Offense count: 1
|
16
|
+
# Configuration parameters: Exclude.
|
17
|
+
Style/FileName:
|
18
|
+
Exclude:
|
19
|
+
- 'lib/omniauth-homeaway.rb'
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
omniauth-homeaway (0.1.0)
|
5
|
+
omniauth (~> 1.1)
|
6
|
+
omniauth-oauth2 (< 1.4)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
ast (2.2.0)
|
12
|
+
diff-lcs (1.2.5)
|
13
|
+
faraday (0.9.2)
|
14
|
+
multipart-post (>= 1.2, < 3)
|
15
|
+
hashie (3.4.3)
|
16
|
+
jwt (1.5.1)
|
17
|
+
multi_json (1.11.2)
|
18
|
+
multi_xml (0.5.5)
|
19
|
+
multipart-post (2.0.0)
|
20
|
+
oauth2 (1.1.0)
|
21
|
+
faraday (>= 0.8, < 0.10)
|
22
|
+
jwt (~> 1.0, < 1.5.2)
|
23
|
+
multi_json (~> 1.3)
|
24
|
+
multi_xml (~> 0.5)
|
25
|
+
rack (>= 1.2, < 3)
|
26
|
+
omniauth (1.3.1)
|
27
|
+
hashie (>= 1.2, < 4)
|
28
|
+
rack (>= 1.0, < 3)
|
29
|
+
omniauth-oauth2 (1.3.1)
|
30
|
+
oauth2 (~> 1.0)
|
31
|
+
omniauth (~> 1.2)
|
32
|
+
parser (2.3.0.6)
|
33
|
+
ast (~> 2.2)
|
34
|
+
powerpack (0.1.1)
|
35
|
+
rack (1.6.4)
|
36
|
+
rainbow (2.1.0)
|
37
|
+
rake (10.5.0)
|
38
|
+
rspec (3.4.0)
|
39
|
+
rspec-core (~> 3.4.0)
|
40
|
+
rspec-expectations (~> 3.4.0)
|
41
|
+
rspec-mocks (~> 3.4.0)
|
42
|
+
rspec-core (3.4.3)
|
43
|
+
rspec-support (~> 3.4.0)
|
44
|
+
rspec-expectations (3.4.0)
|
45
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
46
|
+
rspec-support (~> 3.4.0)
|
47
|
+
rspec-mocks (3.4.1)
|
48
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
49
|
+
rspec-support (~> 3.4.0)
|
50
|
+
rspec-support (3.4.1)
|
51
|
+
rubocop (0.37.2)
|
52
|
+
parser (>= 2.3.0.4, < 3.0)
|
53
|
+
powerpack (~> 0.1)
|
54
|
+
rainbow (>= 1.99.1, < 3.0)
|
55
|
+
ruby-progressbar (~> 1.7)
|
56
|
+
unicode-display_width (~> 0.3)
|
57
|
+
ruby-progressbar (1.7.5)
|
58
|
+
unicode-display_width (0.3.1)
|
59
|
+
|
60
|
+
PLATFORMS
|
61
|
+
ruby
|
62
|
+
|
63
|
+
DEPENDENCIES
|
64
|
+
omniauth-homeaway!
|
65
|
+
rake
|
66
|
+
rspec
|
67
|
+
rubocop
|
68
|
+
|
69
|
+
BUNDLED WITH
|
70
|
+
1.11.2
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
[![Build Status](https://travis-ci.org/BookingSync/omniauth-homeaway.svg?branch=master)](https://travis-ci.org/BookingSync/omniauth-homeaway)
|
2
|
+
|
3
|
+
# OmniAuth HomeAway
|
4
|
+
|
5
|
+
This is an OmniAuth 1.1 strategy for authenticating to HomeAway. To
|
6
|
+
use it, you'll need to sign up for an OAuth2 Application ID and Secret
|
7
|
+
on the [HomeAway Application's Registration Page](https://www.homeaway.com/platform/).
|
8
|
+
|
9
|
+
## Installing
|
10
|
+
|
11
|
+
Add to your `Gemfile`:
|
12
|
+
|
13
|
+
```ruby
|
14
|
+
gem 'omniauth-homeaway'
|
15
|
+
```
|
16
|
+
|
17
|
+
Then `bundle install`.
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
`OmniAuth::Strategies::HomeAway` is simply a Rack middleware. Read the OmniAuth 1.1 docs for detailed instructions: https://github.com/intridea/omniauth.
|
22
|
+
|
23
|
+
Here's a quick example, adding the middleware to a Rails app in `config/initializers/omniauth.rb`:
|
24
|
+
|
25
|
+
```ruby
|
26
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
27
|
+
provider :homeaway, ENV['HOMEAWAY_APPLICATION_ID'], ENV['HOMEAWAY_SECRET']
|
28
|
+
end
|
29
|
+
```
|
30
|
+
|
31
|
+
## Supported Rubies
|
32
|
+
|
33
|
+
OmniAuth BookingSync is tested under 2.0, 2.1, 2.2, Ruby-head, JRuby.
|
34
|
+
|
35
|
+
[![CI Build
|
36
|
+
Status](https://secure.travis-ci.org/BookingSync/omniauth-homeaway.png)](http://travis-ci.org/BookingSync/omniauth-homeaway)
|
37
|
+
|
38
|
+
## Other Ruby libraries to connect to HomeAway API
|
39
|
+
|
40
|
+
* [homeaway-api](https://github.com/homeaway/homeaway_api_ruby) - By HomeAway
|
41
|
+
|
42
|
+
## License
|
43
|
+
|
44
|
+
Copyright (c) 2016 [BookingSync.com](http://www.bookingsync.com)
|
45
|
+
|
46
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
47
|
+
|
48
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
49
|
+
|
50
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/example/Gemfile
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
PATH
|
2
|
+
remote: /Users/seb/Work/Websites/BookingSync/gems/omniauth-homeaway
|
3
|
+
specs:
|
4
|
+
omniauth-homeaway (0.1.0)
|
5
|
+
omniauth (~> 1.1)
|
6
|
+
omniauth-oauth2 (< 1.4)
|
7
|
+
|
8
|
+
GEM
|
9
|
+
specs:
|
10
|
+
faraday (0.9.2)
|
11
|
+
multipart-post (>= 1.2, < 3)
|
12
|
+
hashie (3.4.3)
|
13
|
+
json (1.8.3)
|
14
|
+
jwt (1.5.1)
|
15
|
+
multi_json (1.11.2)
|
16
|
+
multi_xml (0.5.5)
|
17
|
+
multipart-post (2.0.0)
|
18
|
+
oauth2 (1.1.0)
|
19
|
+
faraday (>= 0.8, < 0.10)
|
20
|
+
jwt (~> 1.0, < 1.5.2)
|
21
|
+
multi_json (~> 1.3)
|
22
|
+
multi_xml (~> 0.5)
|
23
|
+
rack (>= 1.2, < 3)
|
24
|
+
omniauth (1.3.1)
|
25
|
+
hashie (>= 1.2, < 4)
|
26
|
+
rack (>= 1.0, < 3)
|
27
|
+
omniauth-oauth2 (1.3.1)
|
28
|
+
oauth2 (~> 1.0)
|
29
|
+
omniauth (~> 1.2)
|
30
|
+
rack (1.6.4)
|
31
|
+
rack-protection (1.5.3)
|
32
|
+
rack
|
33
|
+
sinatra (1.4.6)
|
34
|
+
rack (~> 1.4)
|
35
|
+
rack-protection (~> 1.4)
|
36
|
+
tilt (>= 1.3, < 3)
|
37
|
+
tilt (2.0.2)
|
38
|
+
|
39
|
+
PLATFORMS
|
40
|
+
ruby
|
41
|
+
|
42
|
+
DEPENDENCIES
|
43
|
+
json
|
44
|
+
omniauth-homeaway!
|
45
|
+
sinatra
|
46
|
+
|
47
|
+
BUNDLED WITH
|
48
|
+
1.11.2
|
data/example/ReadMe.md
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# HomeAway OAuth Helper
|
2
|
+
|
3
|
+
Small sinatra application to help you get your OAuth Token for your HomeAway Application.
|
4
|
+
This is specially useful to play around HomeAway API.
|
5
|
+
|
6
|
+
## Usage
|
7
|
+
|
8
|
+
### Requirements:
|
9
|
+
|
10
|
+
[POW](http://pow.cx/) - To run this Sinatra application.
|
11
|
+
[Tunnelss](https://github.com/rchampourlier/tunnelss) - To use SSL
|
12
|
+
|
13
|
+
_Note: Tricks for [persiting SSL with Tunnelss over reboot](http://www.sebgrosjean.com/en/news/2014/2/9/rails-with-ssl-in-development-with-pow-and-tunnels)_
|
14
|
+
|
15
|
+
### 1) Install dependencies
|
16
|
+
|
17
|
+
```sh
|
18
|
+
bundle install
|
19
|
+
```
|
20
|
+
|
21
|
+
### 2) Setup your HomeAway Application credentials
|
22
|
+
|
23
|
+
```sh
|
24
|
+
cp .powenv.sample .powenv
|
25
|
+
```
|
26
|
+
|
27
|
+
Edit the `HOMEAWAY_CLIENT_ID` and `HOMEAWAY_CLIENT_SECRET` environment variables from the `.powenv` file.
|
28
|
+
|
29
|
+
### 3) Restart Pow
|
30
|
+
|
31
|
+
Make sure to restart Pow, using:
|
32
|
+
|
33
|
+
```sh
|
34
|
+
touch tmp/restart.txt
|
35
|
+
```
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
Copyright (c) 2016 [BookingSync.com](http://www.bookingsync.com)
|
40
|
+
|
41
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
42
|
+
|
43
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
44
|
+
|
45
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/example/config.ru
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require "sinatra"
|
2
|
+
require "json"
|
3
|
+
require "omniauth-homeaway"
|
4
|
+
|
5
|
+
use Rack::Session::Cookie
|
6
|
+
|
7
|
+
# The *state* is ignored as HomeAway OAuth2 provider is currently not supporting it.
|
8
|
+
use OmniAuth::Builder do
|
9
|
+
provider :homeaway, ENV['HOMEAWAY_CLIENT_ID'], ENV['HOMEAWAY_CLIENT_SECRET'], {
|
10
|
+
provider_ignores_state: true
|
11
|
+
}
|
12
|
+
end
|
13
|
+
|
14
|
+
get "/" do
|
15
|
+
<<-HTML
|
16
|
+
<html>
|
17
|
+
<head>
|
18
|
+
<style>
|
19
|
+
body {
|
20
|
+
text-align: center;
|
21
|
+
}
|
22
|
+
|
23
|
+
a {
|
24
|
+
display: inline-block;
|
25
|
+
padding: 10px 20px;
|
26
|
+
font-size: 16px;
|
27
|
+
color: #fff;
|
28
|
+
background-color: #1B57AA;
|
29
|
+
text-decoration: none;
|
30
|
+
border-radius: 4px;
|
31
|
+
margin: 100px auto 0;
|
32
|
+
}
|
33
|
+
|
34
|
+
a:hover {
|
35
|
+
background-color: #2b88dc;
|
36
|
+
}
|
37
|
+
</style>
|
38
|
+
</head>
|
39
|
+
<body>
|
40
|
+
<p><a href="/auth/homeaway">Sign in with HomeAway</a></p>
|
41
|
+
</body>
|
42
|
+
</html>
|
43
|
+
HTML
|
44
|
+
end
|
45
|
+
|
46
|
+
get "/auth/:provider/callback" do
|
47
|
+
request.env["omniauth.auth"].to_hash.to_json
|
48
|
+
end
|
49
|
+
|
50
|
+
get "/auth/failure" do
|
51
|
+
content_type "text/plain"
|
52
|
+
params[:message]
|
53
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require "omniauth-oauth2"
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class HomeAway < OmniAuth::Strategies::OAuth2
|
6
|
+
option :name, "homeaway"
|
7
|
+
|
8
|
+
option :client_options, site: "https://ws.homeaway.com/"
|
9
|
+
|
10
|
+
uid { raw_info["emailAddress"] }
|
11
|
+
|
12
|
+
info do
|
13
|
+
{
|
14
|
+
first_name: raw_info["firstName"],
|
15
|
+
last_name: raw_info["lastName"],
|
16
|
+
email_address: raw_info["emailAddress"]
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
def raw_info
|
21
|
+
@raw_info ||= access_token.get("/public/me").parsed
|
22
|
+
end
|
23
|
+
|
24
|
+
def build_access_token
|
25
|
+
verifier = request.params["code"]
|
26
|
+
|
27
|
+
auth = "Basic #{Base64.strict_encode64("#{options.client_id}:#{options.client_secret}")}"
|
28
|
+
|
29
|
+
client.auth_code.get_token(verifier, { headers: { 'Authorization' => auth } })
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
OmniAuth.config.add_camelization "homeaway", "HomeAway"
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require File.expand_path("../lib/omniauth/homeaway/version", __FILE__)
|
2
|
+
|
3
|
+
Gem::Specification.new do |gem|
|
4
|
+
gem.name = "omniauth-homeaway"
|
5
|
+
gem.version = OmniAuth::HomeAway::VERSION
|
6
|
+
gem.platform = Gem::Platform::RUBY
|
7
|
+
gem.authors = ["Sebastien Grosjean"]
|
8
|
+
gem.email = ["dev@bookingsync.com"]
|
9
|
+
gem.homepage = "https://github.com/bookingsync/omniauth-homeaway"
|
10
|
+
gem.summary = "An OmniAuth 1.1 strategy for HomeAway OAuth2 identification."
|
11
|
+
gem.description = "An OmniAuth 1.1 strategy for HomeAway OAuth2 identification."
|
12
|
+
|
13
|
+
gem.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
gem.require_paths = ["lib"]
|
17
|
+
|
18
|
+
gem.add_dependency "omniauth", "~> 1.1"
|
19
|
+
# this constraint is to change in 1.4 breaking redirect url generation
|
20
|
+
# https://github.com/intridea/omniauth-oauth2/issues/81
|
21
|
+
gem.add_dependency "omniauth-oauth2", "< 1.4"
|
22
|
+
|
23
|
+
gem.add_development_dependency "rspec"
|
24
|
+
gem.add_development_dependency "rake"
|
25
|
+
gem.add_development_dependency "rubocop"
|
26
|
+
end
|
@@ -0,0 +1,83 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "omniauth-homeaway"
|
3
|
+
|
4
|
+
describe OmniAuth::Strategies::HomeAway do
|
5
|
+
before do
|
6
|
+
OmniAuth.config.test_mode = true
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:request) { double("Request", params: {}, cookies: {}, env: {}) }
|
10
|
+
let(:options) { {} }
|
11
|
+
|
12
|
+
subject do
|
13
|
+
OmniAuth::Strategies::HomeAway.new(nil, options).tap do |strategy|
|
14
|
+
allow(strategy).to receive(:request) { request }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
it_should_behave_like "an oauth2 strategy"
|
19
|
+
|
20
|
+
describe '#client' do
|
21
|
+
it "has the correct site" do
|
22
|
+
expect(subject.client.site).to eq("https://ws.homeaway.com/")
|
23
|
+
end
|
24
|
+
|
25
|
+
it "has the correct authorization url" do
|
26
|
+
expect(subject.client.options[:authorize_url]).to eq("/oauth/authorize")
|
27
|
+
end
|
28
|
+
|
29
|
+
it "has the correct token url" do
|
30
|
+
expect(subject.client.options[:token_url]).to eq("/oauth/token")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#callback_path' do
|
35
|
+
it "has the correct callback path" do
|
36
|
+
expect(subject.callback_path).to eq("/auth/homeaway/callback")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#raw_info' do
|
41
|
+
it "fetches account info from public/me" do
|
42
|
+
allow(subject).to receive(:access_token).and_return(double)
|
43
|
+
response = double(parsed: {
|
44
|
+
"firstName" => "Sebastien",
|
45
|
+
"lastName" => "Grosjean",
|
46
|
+
"emailAddress" => "dev@bookingsync.com"
|
47
|
+
})
|
48
|
+
expect(subject.access_token).to receive(:get).with("/public/me").and_return(response)
|
49
|
+
expect(subject.raw_info["firstName"]).to eq "Sebastien"
|
50
|
+
expect(subject.raw_info["lastName"]).to eq "Grosjean"
|
51
|
+
expect(subject.raw_info["emailAddress"]).to eq "dev@bookingsync.com"
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
describe '#info' do
|
56
|
+
it "fetches account info from public/me" do
|
57
|
+
allow(subject).to receive(:access_token).and_return(double)
|
58
|
+
response = double(parsed: {
|
59
|
+
"firstName" => "Sebastien",
|
60
|
+
"lastName" => "Grosjean",
|
61
|
+
"emailAddress" => "dev@bookingsync.com"
|
62
|
+
})
|
63
|
+
expect(subject.access_token).to receive(:get).with("/public/me").and_return(response)
|
64
|
+
expect(subject.info[:first_name]).to eq "Sebastien"
|
65
|
+
expect(subject.info[:last_name]).to eq "Grosjean"
|
66
|
+
expect(subject.info[:email_address]).to eq "dev@bookingsync.com"
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
describe "#build_access_token" do
|
71
|
+
it "authenticate the token request with Basic Auth" do
|
72
|
+
expect(subject).to receive(:request).and_return(double(params: { "code" => "CODE" }))
|
73
|
+
expect(subject.options).to receive(:client_id).and_return("CLIENT_ID")
|
74
|
+
expect(subject.options).to receive(:client_secret).and_return("CLIENT_SECRET")
|
75
|
+
|
76
|
+
allow(subject).to receive(:client).and_return(double)
|
77
|
+
allow(subject.client).to receive(:auth_code).and_return(double)
|
78
|
+
expect(subject.client.auth_code).to receive(:get_token).with("CODE",
|
79
|
+
{ headers: { 'Authorization' => "Basic Q0xJRU5UX0lEOkNMSUVOVF9TRUNSRVQ=" } })
|
80
|
+
subject.build_access_token
|
81
|
+
end
|
82
|
+
end
|
83
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,59 @@
|
|
1
|
+
shared_examples "an oauth2 strategy" do
|
2
|
+
describe '#client' do
|
3
|
+
let(:options) do
|
4
|
+
{ client_options: { "authorize_url" => "https://example.com" } }
|
5
|
+
end
|
6
|
+
|
7
|
+
it "is initialized with symbolized client_options" do
|
8
|
+
expect(subject.client.options[:authorize_url]).to eq "https://example.com"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#authorize_params' do
|
13
|
+
context "when passed as authorize_params" do
|
14
|
+
let(:options) do
|
15
|
+
{ authorize_params: { foo: "bar", baz: "zip" } }
|
16
|
+
end
|
17
|
+
|
18
|
+
it "includes any authorize params passed in the :authorize_params option" do
|
19
|
+
expect(subject.authorize_params["foo"]).to eq("bar")
|
20
|
+
expect(subject.authorize_params["baz"]).to eq("zip")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
context "when passed as authorize_options" do
|
25
|
+
let(:options) do
|
26
|
+
{ authorize_options: [:scope, :foo], scope: "bar", foo: "baz" }
|
27
|
+
end
|
28
|
+
|
29
|
+
it "includes top-level options that are marked as :authorize_options" do
|
30
|
+
expect(subject.authorize_params["scope"]).to eq("bar")
|
31
|
+
expect(subject.authorize_params["foo"]).to eq("baz")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
describe '#token_params' do
|
37
|
+
context "when passed as token_params" do
|
38
|
+
let(:options) do
|
39
|
+
{ token_params: { foo: "bar", baz: "zip" } }
|
40
|
+
end
|
41
|
+
|
42
|
+
it "includes any token params passed in the :token_params option" do
|
43
|
+
expect(subject.token_params["foo"]).to eq("bar")
|
44
|
+
expect(subject.token_params["baz"]).to eq("zip")
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context "when passed as token_options" do
|
49
|
+
let(:options) do
|
50
|
+
{ token_options: [:scope, :foo], scope: "bar", foo: "baz" }
|
51
|
+
end
|
52
|
+
|
53
|
+
it "includes top-level options that are marked as :token_options" do
|
54
|
+
expect(subject.token_params["scope"]).to eq("bar")
|
55
|
+
expect(subject.token_params["foo"]).to eq("baz")
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
metadata
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-homeaway
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Sebastien Grosjean
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-02-24 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'
|
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'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: omniauth-oauth2
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "<"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.4'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "<"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.4'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
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: rake
|
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: rubocop
|
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
|
+
description: An OmniAuth 1.1 strategy for HomeAway OAuth2 identification.
|
84
|
+
email:
|
85
|
+
- dev@bookingsync.com
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files: []
|
89
|
+
files:
|
90
|
+
- ".gitignore"
|
91
|
+
- ".rspec"
|
92
|
+
- ".rubocop.yml"
|
93
|
+
- ".rubocop_todo.yml"
|
94
|
+
- ".travis.yml"
|
95
|
+
- CHANGELOG.md
|
96
|
+
- Gemfile
|
97
|
+
- Gemfile.lock
|
98
|
+
- README.md
|
99
|
+
- Rakefile
|
100
|
+
- example/.powenv.sample
|
101
|
+
- example/Gemfile
|
102
|
+
- example/Gemfile.lock
|
103
|
+
- example/ReadMe.md
|
104
|
+
- example/config.ru
|
105
|
+
- example/homeaway_oauth_helper.rb
|
106
|
+
- lib/omniauth-homeaway.rb
|
107
|
+
- lib/omniauth/homeaway/version.rb
|
108
|
+
- lib/omniauth/strategies/homeaway.rb
|
109
|
+
- omniauth-homeaway.gemspec
|
110
|
+
- spec/omniauth/strategies/homeaway_spec.rb
|
111
|
+
- spec/spec_helper.rb
|
112
|
+
- spec/support/shared_examples.rb
|
113
|
+
homepage: https://github.com/bookingsync/omniauth-homeaway
|
114
|
+
licenses: []
|
115
|
+
metadata: {}
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
require_paths:
|
119
|
+
- lib
|
120
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
126
|
+
requirements:
|
127
|
+
- - ">="
|
128
|
+
- !ruby/object:Gem::Version
|
129
|
+
version: '0'
|
130
|
+
requirements: []
|
131
|
+
rubyforge_project:
|
132
|
+
rubygems_version: 2.4.5.1
|
133
|
+
signing_key:
|
134
|
+
specification_version: 4
|
135
|
+
summary: An OmniAuth 1.1 strategy for HomeAway OAuth2 identification.
|
136
|
+
test_files:
|
137
|
+
- spec/omniauth/strategies/homeaway_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
- spec/support/shared_examples.rb
|
140
|
+
has_rdoc:
|