omniauth-immobilienscout24 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +18 -0
- data/.rspec +3 -0
- data/.travis.yml +8 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +79 -0
- data/Rakefile +6 -0
- data/lib/omniauth-immobilienscout24.rb +2 -0
- data/lib/omniauth-immobilienscout24/version.rb +5 -0
- data/lib/omniauth/strategies/immobilienscout24.rb +42 -0
- data/omniauth-immobilienscout24.gemspec +27 -0
- data/spec/omniauth/strategies/immobilienscout24_spec.rb +75 -0
- data/spec/spec_helper.rb +14 -0
- metadata +156 -0
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 endil GmbH
|
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,79 @@
|
|
1
|
+
# Omniauth ImmobilienScout24
|
2
|
+
|
3
|
+
This gem contains the [ImmobilienScout24](http://www.immobilienscout24.de/) strategy for [OmniAuth](https://github.com/intridea/omniauth/).
|
4
|
+
|
5
|
+
ImmobilienScout24 uses [OAuth 1.0a](http://oauth.net/core/1.0a/). For information on the implementation details check out the [documentation](http://developerwiki.immobilienscout24.de/wiki/Authentication).
|
6
|
+
|
7
|
+
## Preparation
|
8
|
+
|
9
|
+
1. Contact the [ImmobilienScout24 API team](http://developer.immobilienscout24.de/rest-api/rest-api-zugang/) to obtain your CONSUMER_KEY and CONSUMER_SECRET.
|
10
|
+
2. Make sure that you have already installed [OmniAuth](https://github.com/intridea/omniauth/wiki) into your application. Otherwise check out the [installation details](https://github.com/intridea/omniauth), the [documentation](https://github.com/intridea/omniauth/wiki) or follow this excellent [screencast](http://railscasts.com/episodes/241-simple-omniauth-revised) by [Ryan Bates](http://railscasts.com/about).
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
First add the following line to your application's Gemfile:
|
15
|
+
|
16
|
+
```ruby
|
17
|
+
gem 'omniauth-immobilienscout24'
|
18
|
+
```
|
19
|
+
|
20
|
+
Execute the ```bundle``` command to install the gem.
|
21
|
+
|
22
|
+
Next, tell OmniAuth about the ImmobilienScout24 provider. For a Ruby on Rails application, your ```config/initializers/omniauth.rb``` file should look like:
|
23
|
+
|
24
|
+
```ruby
|
25
|
+
Rails.application.config.middleware.use OmniAuth::Builder do
|
26
|
+
provider :immobilienscout24, 'CONSUMER_KEY', 'CONSUMER_SECRET'
|
27
|
+
end
|
28
|
+
```
|
29
|
+
|
30
|
+
Replace CONSUMER_KEY and CONSUMER_SECRET with the values given from the ImmobilienScout24 API team. And also make sure, that __the values are kept secret__!
|
31
|
+
|
32
|
+
After restarting your application, point the authenticating user to ```/auth/immobilienscout24```, the rest will be handled by OmniAuth.
|
33
|
+
|
34
|
+
## Authentication hash
|
35
|
+
|
36
|
+
Here's an example authentication hash available in ```request.env['omniauth.auth']```:
|
37
|
+
|
38
|
+
```ruby
|
39
|
+
{
|
40
|
+
:provider => 'immobilienscout24',
|
41
|
+
:uid => '1234',
|
42
|
+
:info => {
|
43
|
+
:id => '5678',
|
44
|
+
:salutation => 'MALE',
|
45
|
+
:name => 'ABC XYZ'
|
46
|
+
:first_name => 'ABC'
|
47
|
+
:last_name => 'XYZ'
|
48
|
+
:url => 'http://www.example.com',
|
49
|
+
},
|
50
|
+
:credentials => {
|
51
|
+
:token => '123ABC...', # OAuth access_token, which you may want to store
|
52
|
+
:secret => 'abc123...' # OAuth access_secret, which you may want to store
|
53
|
+
},
|
54
|
+
:extra => {
|
55
|
+
:raw_info => {
|
56
|
+
... # data from /api/search/v1.0/searcher/me
|
57
|
+
}
|
58
|
+
}
|
59
|
+
}
|
60
|
+
```
|
61
|
+
|
62
|
+
## Supported Rubies
|
63
|
+
[![Build Status](https://travis-ci.org/endil/omniauth-immobilienscout24.png?branch=master)](https://travis-ci.org/endil/omniauth-immobilienscout24)
|
64
|
+
[![Gem Version](https://badge.fury.io/rb/omniauth-immobilienscout24.png)](https://badge.fury.io/rb/omniauth-immobilienscout24)
|
65
|
+
|
66
|
+
OmniAuth ImmobilienScout24 is tested under 1.8.7, 1.9.2, 1.9.3 and Ruby Enterprise Edition.
|
67
|
+
|
68
|
+
|
69
|
+
## License
|
70
|
+
|
71
|
+
(The MIT License)
|
72
|
+
|
73
|
+
Copyright (c) 2013 by Niels Richter
|
74
|
+
|
75
|
+
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:
|
76
|
+
|
77
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
78
|
+
|
79
|
+
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
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'omniauth/strategies/oauth'
|
2
|
+
|
3
|
+
module OmniAuth
|
4
|
+
module Strategies
|
5
|
+
class ImmobilienScout24 < OmniAuth::Strategies::OAuth
|
6
|
+
|
7
|
+
args [:consumer_key, :consumer_secret]
|
8
|
+
|
9
|
+
option :client_options, {
|
10
|
+
:access_token_path => '/security/oauth/access_token',
|
11
|
+
:authorize_path => '/security/oauth/confirm_access',
|
12
|
+
:request_token_path => '/security/oauth/request_token',
|
13
|
+
:site => 'https://rest.immobilienscout24.de/restapi',
|
14
|
+
}
|
15
|
+
|
16
|
+
info do
|
17
|
+
{
|
18
|
+
:id => raw_info['@id'],
|
19
|
+
:salutation => raw_info['contactDetails']['salutation'],
|
20
|
+
:first_name => raw_info['contactDetails']['firstname'],
|
21
|
+
:last_name => raw_info['contactDetails']['lastname'],
|
22
|
+
:url => raw_info['contactDetails']['homepageUrl']
|
23
|
+
}
|
24
|
+
end
|
25
|
+
|
26
|
+
uid do
|
27
|
+
raw_info['@peid']
|
28
|
+
end
|
29
|
+
|
30
|
+
extra do
|
31
|
+
{ 'raw_info' => raw_info }
|
32
|
+
end
|
33
|
+
|
34
|
+
def raw_info
|
35
|
+
@raw_info ||= MultiJson.decode(access_token.get('/api/search/v1.0/searcher/me', { 'Accept' => 'application/json' }).body)['searcher.searcher']
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
OmniAuth.config.add_camelization 'immobilienscout24', 'ImmobilienScout24'
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'omniauth-immobilienscout24/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = 'omniauth-immobilienscout24'
|
8
|
+
s.version = Omniauth::Immobilienscout24::VERSION
|
9
|
+
s.authors = ['Niels Richter']
|
10
|
+
s.email = ['niels@endil.de']
|
11
|
+
s.description = 'OmniAuth strategy for ImmobilienScout24'
|
12
|
+
s.summary = s.description
|
13
|
+
s.homepage = 'https://github.com/endil/omniauth-immobilienscout24'
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split($/)
|
16
|
+
s.executables = s.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
18
|
+
s.require_paths = ['lib']
|
19
|
+
|
20
|
+
s.add_dependency 'multi_json', '~> 1.3'
|
21
|
+
s.add_runtime_dependency 'omniauth-oauth', '~> 1.0'
|
22
|
+
|
23
|
+
s.add_development_dependency 'rspec', '~> 2.7'
|
24
|
+
s.add_development_dependency 'rake'
|
25
|
+
s.add_development_dependency 'webmock'
|
26
|
+
s.add_development_dependency 'rack-test'
|
27
|
+
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'OmniAuth::Strategies::ImmobilienScout24' do
|
4
|
+
subject do
|
5
|
+
OmniAuth::Strategies::ImmobilienScout24.new(nil, @options || {})
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should add a camelization for itself' do
|
9
|
+
OmniAuth::Utils.camelize('immobilienscout24').should == 'ImmobilienScout24'
|
10
|
+
end
|
11
|
+
|
12
|
+
context 'client options' do
|
13
|
+
it 'has correct site' do
|
14
|
+
subject.options.client_options.site.should eq('https://rest.immobilienscout24.de/restapi')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'has correct request token path' do
|
18
|
+
subject.options.client_options.request_token_path.should eq('/security/oauth/request_token')
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'has correct access token path' do
|
22
|
+
subject.options.client_options.access_token_path.should eq('/security/oauth/access_token')
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'has correct authorize path' do
|
26
|
+
subject.options.client_options.authorize_path.should eq('/security/oauth/confirm_access')
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
context '#uid' do
|
31
|
+
before :each do
|
32
|
+
subject.stub(:raw_info) { { '@peid' => '123' } }
|
33
|
+
end
|
34
|
+
|
35
|
+
it 'returns the @peid from raw_info' do
|
36
|
+
subject.uid.should eq('123')
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context '#info' do
|
41
|
+
before :each do
|
42
|
+
subject.stub(:raw_info) {
|
43
|
+
{
|
44
|
+
'@id' => '123',
|
45
|
+
'contactDetails' => {
|
46
|
+
'salutation' => 'MALE',
|
47
|
+
'firstname' => 'John',
|
48
|
+
'lastname' => 'Doe',
|
49
|
+
'homepageUrl' => 'http://www.example.com/'
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'returns the @id from raw_info' do
|
56
|
+
subject.info[:id].should eq('123')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'returns the salutation from contactDetails in raw_info' do
|
60
|
+
subject.info[:salutation].should eq('MALE')
|
61
|
+
end
|
62
|
+
|
63
|
+
it 'returns the first_name from contactDetails in raw_info' do
|
64
|
+
subject.info[:first_name].should eq('John')
|
65
|
+
end
|
66
|
+
|
67
|
+
it 'returns the last_name from contactDetails in raw_info' do
|
68
|
+
subject.info[:last_name].should eq('Doe')
|
69
|
+
end
|
70
|
+
|
71
|
+
it 'returns the url from contactDetails in raw_info' do
|
72
|
+
subject.info[:url].should eq('http://www.example.com/')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
$:.unshift File.expand_path('..', __FILE__)
|
2
|
+
$:.unshift File.expand_path('../../lib', __FILE__)
|
3
|
+
|
4
|
+
require 'rspec'
|
5
|
+
require 'rack/test'
|
6
|
+
require 'webmock/rspec'
|
7
|
+
require 'omniauth'
|
8
|
+
require 'omniauth-immobilienscout24'
|
9
|
+
|
10
|
+
RSpec.configure do |config|
|
11
|
+
config.include WebMock::API
|
12
|
+
config.include Rack::Test::Methods
|
13
|
+
config.extend OmniAuth::Test::StrategyMacros, :type => :strategy
|
14
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: omniauth-immobilienscout24
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Niels Richter
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-02-21 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: multi_json
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: omniauth-oauth
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '1.0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '2.7'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.7'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: rake
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ! '>='
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '0'
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ! '>='
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '0'
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: webmock
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ! '>='
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rack-test
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ! '>='
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ! '>='
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0'
|
110
|
+
description: OmniAuth strategy for ImmobilienScout24
|
111
|
+
email:
|
112
|
+
- niels@endil.de
|
113
|
+
executables: []
|
114
|
+
extensions: []
|
115
|
+
extra_rdoc_files: []
|
116
|
+
files:
|
117
|
+
- .gitignore
|
118
|
+
- .rspec
|
119
|
+
- .travis.yml
|
120
|
+
- Gemfile
|
121
|
+
- LICENSE.txt
|
122
|
+
- README.md
|
123
|
+
- Rakefile
|
124
|
+
- lib/omniauth-immobilienscout24.rb
|
125
|
+
- lib/omniauth-immobilienscout24/version.rb
|
126
|
+
- lib/omniauth/strategies/immobilienscout24.rb
|
127
|
+
- omniauth-immobilienscout24.gemspec
|
128
|
+
- spec/omniauth/strategies/immobilienscout24_spec.rb
|
129
|
+
- spec/spec_helper.rb
|
130
|
+
homepage: https://github.com/endil/omniauth-immobilienscout24
|
131
|
+
licenses: []
|
132
|
+
post_install_message:
|
133
|
+
rdoc_options: []
|
134
|
+
require_paths:
|
135
|
+
- lib
|
136
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
137
|
+
none: false
|
138
|
+
requirements:
|
139
|
+
- - ! '>='
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - ! '>='
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
version: '0'
|
148
|
+
requirements: []
|
149
|
+
rubyforge_project:
|
150
|
+
rubygems_version: 1.8.24
|
151
|
+
signing_key:
|
152
|
+
specification_version: 3
|
153
|
+
summary: OmniAuth strategy for ImmobilienScout24
|
154
|
+
test_files:
|
155
|
+
- spec/omniauth/strategies/immobilienscout24_spec.rb
|
156
|
+
- spec/spec_helper.rb
|