omniauth-facebook 3.0.0 → 4.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -1
- data/.travis.yml +6 -10
- data/CHANGELOG.md +19 -9
- data/README.md +39 -54
- data/Rakefile +1 -1
- data/example/Gemfile +1 -1
- data/example/Gemfile.lock +24 -23
- data/example/app.rb +47 -55
- data/example/config.ru +2 -2
- data/lib/omniauth/facebook/version.rb +1 -1
- data/lib/omniauth/strategies/facebook.rb +11 -15
- data/test/strategy_test.rb +31 -37
- data/test/support/shared_examples.rb +7 -7
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b471d95eff279be1902d7aab1ea9762d8388112f
|
4
|
+
data.tar.gz: 8fd01eb76108e6d05bd9ef3585ad8fb505d6327e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc918011a72744c646376fb16e499ed9333552c906899e9433d73244b75bd272a17c5020958de2f311301a449b0035685d8c3a1123207ae8dc8be49352b43392
|
7
|
+
data.tar.gz: 35e6d31f3a277fe98d6c3454f6c7d0306d9a4c62deaacd767804bdec69be576bdbcc35597bf5280212cedab657bd944e96e8f376663ecae74d5114ab80f7a850
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,16 +1,12 @@
|
|
1
1
|
before_install:
|
2
2
|
- gem update bundler
|
3
3
|
- bundle --version
|
4
|
-
- gem update --system
|
4
|
+
- gem update --system
|
5
5
|
- gem --version
|
6
6
|
rvm:
|
7
|
-
-
|
8
|
-
- 1.9.2
|
9
|
-
- 1.9.3
|
10
|
-
- 2.0.0
|
7
|
+
- 2.2
|
11
8
|
- 2.1
|
12
|
-
-
|
13
|
-
-
|
14
|
-
|
15
|
-
|
16
|
-
- rvm: rbx
|
9
|
+
- 2.0
|
10
|
+
- 1.9.3
|
11
|
+
- jruby-19mode
|
12
|
+
- rbx-2
|
data/CHANGELOG.md
CHANGED
@@ -1,29 +1,39 @@
|
|
1
|
+
## 4.0.0 (Unreleased)
|
2
|
+
|
3
|
+
Changes:
|
4
|
+
|
5
|
+
- drop support for Ruby < 1.9.3 (@mkdynamic)
|
6
|
+
- switch to versioned FB APIs, currently using v2.6 (#245, @printercu, @mkdynamic)
|
7
|
+
- remove deprecated :nickname field from README example (#223, @abelorian)
|
8
|
+
- add Ruby 2.2 to CI (#225, @tricknotes, @mkdynamic)
|
9
|
+
- update example app (@mkynamic)
|
10
|
+
|
1
11
|
## 3.0.0 (2015-10-26)
|
2
12
|
|
3
13
|
Changes:
|
4
14
|
|
5
|
-
|
6
|
-
|
7
|
-
|
15
|
+
- remove query string from redirect_uri on callback by default (#221, @gioblu)
|
16
|
+
- signed request parsing extracted to `OmniAuth::Facebook::SignedRequest` class. (#183, @simi, @Vrael)
|
17
|
+
- change default value of `info_fields` to `name,email` for the [graph-api-v2.4](https://developers.facebook.com/blog/post/2015/07/08/graph-api-v2.4/). ([#209](https://github.com/mkdynamic/omniauth-facebook/pull/209))
|
8
18
|
|
9
19
|
## 2.0.1 (2015-02-21)
|
10
20
|
|
11
21
|
Bugfixes:
|
12
22
|
|
13
|
-
|
14
|
-
|
23
|
+
- allow versioning by not forcing absolute path for graph requests (#180, @frausto)
|
24
|
+
- allow the image_size option to be set as a symbol. (#182, @jgrau)
|
15
25
|
|
16
26
|
## 2.0.0 (2014-08-07)
|
17
27
|
|
18
28
|
Changes:
|
19
29
|
|
20
|
-
|
30
|
+
- remove support for canvas app flow (765ed9, @mkdynamic)
|
21
31
|
|
22
32
|
Bugfixes:
|
23
33
|
|
24
|
-
|
25
|
-
|
26
|
-
|
34
|
+
- bump omniauth-oauth2 dependency which addresses CVE-2012-6134 (#162, @linedotstar)
|
35
|
+
- rescue `NoAuthorizationCodeError` in callback_phase (a0036b, @tomoya55)
|
36
|
+
- fix CSRF exception when using FB JS SDK and parsing signed request (765ed9, @mkdynamic)
|
27
37
|
|
28
38
|
## 1.6.0 (2014-01-13)
|
29
39
|
|
data/README.md
CHANGED
@@ -1,11 +1,5 @@
|
|
1
|
-
**IMPORTANT: If you're running < 1.5.1, please upgrade to the latest version to address 3 security vulnerabilities.
|
2
|
-
More details [here](https://github.com/mkdynamic/omniauth-facebook/wiki/CSRF-vulnerability:-CVE-2013-4562), [here](https://github.com/mkdynamic/omniauth-facebook/wiki/Access-token-vulnerability:-CVE-2013-4593) and [here](http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2012-6134).**
|
3
|
-
|
4
|
-
---
|
5
|
-
|
6
1
|
# OmniAuth Facebook [![Build Status](https://secure.travis-ci.org/mkdynamic/omniauth-facebook.svg?branch=master)](https://travis-ci.org/mkdynamic/omniauth-facebook) [![Gem Version](https://img.shields.io/gem/v/omniauth-facebook.svg)](https://rubygems.org/gems/omniauth-facebook)
|
7
2
|
|
8
|
-
|
9
3
|
**These notes are based on master, please see tags for README pertaining to specific releases.**
|
10
4
|
|
11
5
|
Facebook OAuth2 Strategy for OmniAuth.
|
@@ -56,23 +50,24 @@ For example, to request `email`, `user_birthday` and `read_stream` permissions a
|
|
56
50
|
```ruby
|
57
51
|
Rails.application.config.middleware.use OmniAuth::Builder do
|
58
52
|
provider :facebook, ENV['FACEBOOK_KEY'], ENV['FACEBOOK_SECRET'],
|
59
|
-
:
|
53
|
+
scope: 'email,user_birthday,read_stream', display: 'popup'
|
60
54
|
end
|
61
55
|
```
|
62
56
|
|
63
57
|
### API Version
|
64
58
|
|
65
|
-
OmniAuth Facebook uses
|
59
|
+
OmniAuth Facebook uses versioned API endpoints by default (current v2.6). You can configure a different version via `client_options` hash passed to `provider`. For example:
|
66
60
|
|
67
61
|
```ruby
|
68
62
|
use OmniAuth::Builder do
|
69
63
|
provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'],
|
70
|
-
:
|
71
|
-
:
|
72
|
-
:
|
64
|
+
client_options: {
|
65
|
+
site: 'https://graph.facebook.com/v2.6',
|
66
|
+
authorize_url: "https://www.facebook.com/v2.6/dialog/oauth"
|
73
67
|
}
|
74
68
|
end
|
75
69
|
```
|
70
|
+
|
76
71
|
### Per-Request Options
|
77
72
|
|
78
73
|
If you want to set the `display` format, `auth_type`, or `scope` on a per-request basis, you can just pass it to the OmniAuth request phase URL, for example: `/auth/facebook?display=popup` or `/auth/facebook?scope=email`.
|
@@ -83,39 +78,38 @@ Here's an example *Auth Hash* available in `request.env['omniauth.auth']`:
|
|
83
78
|
|
84
79
|
```ruby
|
85
80
|
{
|
86
|
-
:
|
87
|
-
:
|
88
|
-
:
|
89
|
-
:
|
90
|
-
:
|
91
|
-
:
|
92
|
-
:
|
93
|
-
:
|
94
|
-
:
|
95
|
-
:
|
96
|
-
:
|
97
|
-
:verified => true
|
81
|
+
provider: 'facebook',
|
82
|
+
uid: '1234567',
|
83
|
+
info: {
|
84
|
+
email: 'joe@bloggs.com',
|
85
|
+
name: 'Joe Bloggs',
|
86
|
+
first_name: 'Joe',
|
87
|
+
last_name: 'Bloggs',
|
88
|
+
image: 'http://graph.facebook.com/1234567/picture?type=square',
|
89
|
+
urls: { Facebook: 'http://www.facebook.com/jbloggs' },
|
90
|
+
location: 'Palo Alto, California',
|
91
|
+
verified: true
|
98
92
|
},
|
99
|
-
:
|
100
|
-
:
|
101
|
-
:
|
102
|
-
:
|
93
|
+
credentials: {
|
94
|
+
token: 'ABCDEF...', # OAuth 2.0 access_token, which you may wish to store
|
95
|
+
expires_at: 1321747205, # when the access token expires (it always will)
|
96
|
+
expires: true # this will always be true
|
103
97
|
},
|
104
|
-
:
|
105
|
-
:
|
106
|
-
:
|
107
|
-
:
|
108
|
-
:
|
109
|
-
:
|
110
|
-
:
|
111
|
-
:
|
112
|
-
:
|
113
|
-
:
|
114
|
-
:
|
115
|
-
:
|
116
|
-
:
|
117
|
-
:
|
118
|
-
:
|
98
|
+
extra: {
|
99
|
+
raw_info: {
|
100
|
+
id: '1234567',
|
101
|
+
name: 'Joe Bloggs',
|
102
|
+
first_name: 'Joe',
|
103
|
+
last_name: 'Bloggs',
|
104
|
+
link: 'http://www.facebook.com/jbloggs',
|
105
|
+
username: 'jbloggs',
|
106
|
+
location: { id: '123456789', name: 'Palo Alto, California' },
|
107
|
+
gender: 'male',
|
108
|
+
email: 'joe@bloggs.com',
|
109
|
+
timezone: -8,
|
110
|
+
locale: 'en_US',
|
111
|
+
verified: true,
|
112
|
+
updated_time: '2011-11-11T06:21:03+0000'
|
119
113
|
}
|
120
114
|
}
|
121
115
|
}
|
@@ -157,15 +151,9 @@ If you use the server-side flow, Facebook will give you back a longer lived acce
|
|
157
151
|
|
158
152
|
## Supported Rubies
|
159
153
|
|
160
|
-
|
161
|
-
|
162
|
-
-
|
163
|
-
- MRI 2.0.0
|
164
|
-
- MRI 1.9.3
|
165
|
-
- MRI 1.9.2
|
166
|
-
- MRI 1.8.7
|
167
|
-
- JRuby 1.7.9
|
168
|
-
- Rubinius (latest stable)
|
154
|
+
- Ruby MRI (1.9.3+)
|
155
|
+
- JRuby (1.9 mode)
|
156
|
+
- RBX (2.1.1+)
|
169
157
|
|
170
158
|
## License
|
171
159
|
|
@@ -176,6 +164,3 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
|
|
176
164
|
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
177
165
|
|
178
166
|
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.
|
179
|
-
|
180
|
-
|
181
|
-
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/mkdynamic/omniauth-facebook/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
|
data/Rakefile
CHANGED
data/example/Gemfile
CHANGED
data/example/Gemfile.lock
CHANGED
@@ -1,53 +1,51 @@
|
|
1
1
|
PATH
|
2
2
|
remote: ../
|
3
3
|
specs:
|
4
|
-
omniauth-facebook (
|
4
|
+
omniauth-facebook (3.0.0)
|
5
5
|
omniauth-oauth2 (~> 1.2)
|
6
6
|
|
7
7
|
GEM
|
8
8
|
remote: https://rubygems.org/
|
9
9
|
specs:
|
10
|
-
backports (3.
|
11
|
-
faraday (0.9.
|
10
|
+
backports (3.6.8)
|
11
|
+
faraday (0.9.2)
|
12
12
|
multipart-post (>= 1.2, < 3)
|
13
|
-
hashie (3.
|
14
|
-
jwt (1.
|
15
|
-
multi_json (1.
|
13
|
+
hashie (3.4.4)
|
14
|
+
jwt (1.5.1)
|
15
|
+
multi_json (1.12.1)
|
16
16
|
multi_xml (0.5.5)
|
17
17
|
multipart-post (2.0.0)
|
18
|
-
oauth2 (1.
|
18
|
+
oauth2 (1.1.0)
|
19
19
|
faraday (>= 0.8, < 0.10)
|
20
|
-
jwt (~> 1.0)
|
20
|
+
jwt (~> 1.0, < 1.5.2)
|
21
21
|
multi_json (~> 1.3)
|
22
22
|
multi_xml (~> 0.5)
|
23
|
-
rack (
|
24
|
-
omniauth (1.
|
23
|
+
rack (>= 1.2, < 3)
|
24
|
+
omniauth (1.3.1)
|
25
25
|
hashie (>= 1.2, < 4)
|
26
|
-
rack (
|
27
|
-
omniauth-oauth2 (1.
|
28
|
-
faraday (>= 0.8, < 0.10)
|
29
|
-
multi_json (~> 1.3)
|
26
|
+
rack (>= 1.0, < 3)
|
27
|
+
omniauth-oauth2 (1.4.0)
|
30
28
|
oauth2 (~> 1.0)
|
31
29
|
omniauth (~> 1.2)
|
32
|
-
rack (1.
|
33
|
-
rack-protection (1.5.
|
30
|
+
rack (1.6.4)
|
31
|
+
rack-protection (1.5.3)
|
34
32
|
rack
|
35
|
-
rack-test (0.6.
|
33
|
+
rack-test (0.6.3)
|
36
34
|
rack (>= 1.0)
|
37
|
-
sinatra (1.4.
|
38
|
-
rack (~> 1.
|
35
|
+
sinatra (1.4.7)
|
36
|
+
rack (~> 1.5)
|
39
37
|
rack-protection (~> 1.4)
|
40
|
-
tilt (
|
41
|
-
sinatra-contrib (1.4.
|
38
|
+
tilt (>= 1.3, < 3)
|
39
|
+
sinatra-contrib (1.4.7)
|
42
40
|
backports (>= 2.0)
|
43
41
|
multi_json
|
44
42
|
rack-protection
|
45
43
|
rack-test
|
46
44
|
sinatra (~> 1.4.0)
|
47
|
-
tilt (
|
45
|
+
tilt (>= 1.3, < 3)
|
48
46
|
sinatra-reloader (1.0)
|
49
47
|
sinatra-contrib
|
50
|
-
tilt (
|
48
|
+
tilt (2.0.5)
|
51
49
|
|
52
50
|
PLATFORMS
|
53
51
|
ruby
|
@@ -56,3 +54,6 @@ DEPENDENCIES
|
|
56
54
|
omniauth-facebook!
|
57
55
|
sinatra
|
58
56
|
sinatra-reloader
|
57
|
+
|
58
|
+
BUNDLED WITH
|
59
|
+
1.12.5
|
data/example/app.rb
CHANGED
@@ -6,88 +6,80 @@ require 'yaml'
|
|
6
6
|
set :run, false
|
7
7
|
set :raise_errors, true
|
8
8
|
|
9
|
-
#
|
10
|
-
log = File.new("app.log", "a+")
|
11
|
-
$stdout.reopen(log)
|
12
|
-
$stderr.reopen(log)
|
13
|
-
$stderr.sync = true
|
14
|
-
$stdout.sync = true
|
15
|
-
|
16
|
-
# server-side flow
|
9
|
+
# REQUEST STEP (server-side flow)
|
17
10
|
get '/server-side' do
|
18
|
-
# NOTE: You would just hit this endpoint directly from the browser in a real app. The redirect is
|
19
|
-
# explicit declare this server-side flow.
|
11
|
+
# NOTE: You would just hit this endpoint directly from the browser in a real app. The redirect is
|
12
|
+
# just here to explicit declare this server-side flow.
|
20
13
|
redirect '/auth/facebook'
|
21
14
|
end
|
22
15
|
|
23
|
-
# client-side flow
|
16
|
+
# REQUEST STEP (client-side flow)
|
24
17
|
get '/client-side' do
|
25
18
|
content_type 'text/html'
|
26
|
-
# NOTE: When you enable cookie below in the FB.init call the GET request in the FB.login callback
|
27
|
-
# request in a cookie back the OmniAuth callback which will parse out the
|
28
|
-
# access_token with it.
|
29
|
-
<<-
|
19
|
+
# NOTE: When you enable cookie below in the FB.init call the GET request in the FB.login callback
|
20
|
+
# will send a signed request in a cookie back the OmniAuth callback which will parse out the
|
21
|
+
# authorization code and obtain an access_token with it.
|
22
|
+
<<-HTML
|
30
23
|
<html>
|
31
24
|
<head>
|
32
25
|
<title>Client-side Flow Example</title>
|
33
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/
|
34
|
-
</head>
|
35
|
-
<body>
|
36
|
-
<div id="fb-root"></div>
|
37
|
-
|
26
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js" type="text/javascript"></script>
|
38
27
|
<script type="text/javascript">
|
39
28
|
window.fbAsyncInit = function() {
|
40
29
|
FB.init({
|
41
|
-
appId
|
42
|
-
|
43
|
-
cookie
|
44
|
-
xfbml : true // parse XFBML
|
30
|
+
appId: '#{ENV['APP_ID']}',
|
31
|
+
version: 'v2.6',
|
32
|
+
cookie: true // IMPORTANT must enable cookies to allow the server to access the session
|
45
33
|
});
|
34
|
+
console.log("fb init");
|
46
35
|
};
|
47
36
|
|
48
|
-
(function(d)
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
$(function() {
|
56
|
-
$('a').click(function(e) {
|
57
|
-
e.preventDefault();
|
58
|
-
|
59
|
-
FB.login(function(response) {
|
60
|
-
if (response.authResponse) {
|
61
|
-
$('#connect').html('Connected! Hitting OmniAuth callback (GET /auth/facebook/callback)...');
|
62
|
-
|
63
|
-
// since we have cookies enabled, this request will allow omniauth to parse
|
64
|
-
// out the auth code from the signed request in the fbsr_XXX cookie
|
65
|
-
$.getJSON('/auth/facebook/callback', function(json) {
|
66
|
-
$('#connect').html('Connected! Callback complete.');
|
67
|
-
$('#results').html(JSON.stringify(json));
|
68
|
-
});
|
69
|
-
}
|
70
|
-
}, { scope: 'email,read_stream', state: 'abc123' });
|
71
|
-
});
|
72
|
-
});
|
37
|
+
(function(d, s, id){
|
38
|
+
var js, fjs = d.getElementsByTagName(s)[0];
|
39
|
+
if (d.getElementById(id)) {return;}
|
40
|
+
js = d.createElement(s); js.id = id;
|
41
|
+
js.src = "//connect.facebook.net/en_US/sdk.js";
|
42
|
+
fjs.parentNode.insertBefore(js, fjs);
|
43
|
+
}(document, 'script', 'facebook-jssdk'));
|
73
44
|
</script>
|
45
|
+
</head>
|
46
|
+
<body>
|
47
|
+
<div id="fb-root"></div>
|
74
48
|
|
75
49
|
<p id="connect">
|
76
50
|
<a href="#">Connect to FB!</a>
|
77
51
|
</p>
|
78
52
|
|
79
53
|
<p id="results" />
|
54
|
+
|
55
|
+
<script type="text/javascript">
|
56
|
+
$('a').click(function(e) {
|
57
|
+
e.preventDefault();
|
58
|
+
|
59
|
+
FB.login(function(response) {
|
60
|
+
console.log(response);
|
61
|
+
if (response.authResponse) {
|
62
|
+
$('#connect').html('Connected! Hitting OmniAuth callback (GET /auth/facebook/callback)...');
|
63
|
+
|
64
|
+
// since we have cookies enabled, this request will allow omniauth to parse
|
65
|
+
// out the auth code from the signed request in the fbsr_XXX cookie
|
66
|
+
$.getJSON('/auth/facebook/callback', function(json) {
|
67
|
+
$('#connect').html('Connected! Callback complete.');
|
68
|
+
$('#results').html(JSON.stringify(json));
|
69
|
+
});
|
70
|
+
}
|
71
|
+
}); // if you want custom scopes, pass them as an extra, final argument to FB.login
|
72
|
+
});
|
73
|
+
</script>
|
80
74
|
</body>
|
81
75
|
</html>
|
82
|
-
|
76
|
+
HTML
|
83
77
|
end
|
84
78
|
|
79
|
+
# CALLBACK STEP
|
80
|
+
# - redirected here for server-side flow
|
81
|
+
# - ajax request made here for client-side flow
|
85
82
|
get '/auth/:provider/callback' do
|
86
83
|
content_type 'application/json'
|
87
84
|
MultiJson.encode(request.env)
|
88
85
|
end
|
89
|
-
|
90
|
-
get '/auth/failure' do
|
91
|
-
content_type 'application/json'
|
92
|
-
MultiJson.encode(request.env)
|
93
|
-
end
|
data/example/config.ru
CHANGED
@@ -2,10 +2,10 @@ require 'bundler/setup'
|
|
2
2
|
require 'omniauth-facebook'
|
3
3
|
require './app.rb'
|
4
4
|
|
5
|
-
use Rack::Session::Cookie, :
|
5
|
+
use Rack::Session::Cookie, secret: 'abc123'
|
6
6
|
|
7
7
|
use OmniAuth::Builder do
|
8
|
-
provider :facebook, ENV['APP_ID'], ENV['APP_SECRET']
|
8
|
+
provider :facebook, ENV['APP_ID'], ENV['APP_SECRET']
|
9
9
|
end
|
10
10
|
|
11
11
|
run Sinatra::Application
|
@@ -12,18 +12,14 @@ module OmniAuth
|
|
12
12
|
DEFAULT_SCOPE = 'email'
|
13
13
|
|
14
14
|
option :client_options, {
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
18
|
-
}
|
19
|
-
|
20
|
-
option :token_params, {
|
21
|
-
:parse => :query
|
15
|
+
site: 'https://graph.facebook.com/v2.6',
|
16
|
+
authorize_url: "https://www.facebook.com/v2.6/dialog/oauth",
|
17
|
+
token_url: 'oauth/access_token'
|
22
18
|
}
|
23
19
|
|
24
20
|
option :access_token_options, {
|
25
|
-
:
|
26
|
-
:
|
21
|
+
header_format: 'OAuth %s',
|
22
|
+
param_name: 'access_token'
|
27
23
|
}
|
28
24
|
|
29
25
|
option :authorize_options, [:scope, :display, :auth_type]
|
@@ -59,11 +55,11 @@ module OmniAuth
|
|
59
55
|
end
|
60
56
|
|
61
57
|
def info_options
|
62
|
-
params = {:
|
63
|
-
params.merge!({:
|
64
|
-
params.merge!({:
|
58
|
+
params = {appsecret_proof: appsecret_proof}
|
59
|
+
params.merge!({fields: (options[:info_fields] || 'name,email')})
|
60
|
+
params.merge!({locale: options[:locale]}) if options[:locale]
|
65
61
|
|
66
|
-
{ :
|
62
|
+
{ params: params }
|
67
63
|
end
|
68
64
|
|
69
65
|
def callback_phase
|
@@ -162,10 +158,10 @@ module OmniAuth
|
|
162
158
|
def image_url(uid, options)
|
163
159
|
uri_class = options[:secure_image_url] ? URI::HTTPS : URI::HTTP
|
164
160
|
site_uri = URI.parse(client.site)
|
165
|
-
url = uri_class.build({:
|
161
|
+
url = uri_class.build({host: site_uri.host, path: "#{site_uri.path}/#{uid}/picture"})
|
166
162
|
|
167
163
|
query = if options[:image_size].is_a?(String) || options[:image_size].is_a?(Symbol)
|
168
|
-
{ :
|
164
|
+
{ type: options[:image_size] }
|
169
165
|
elsif options[:image_size].is_a?(Hash)
|
170
166
|
options[:image_size]
|
171
167
|
end
|
data/test/strategy_test.rb
CHANGED
@@ -9,15 +9,15 @@ end
|
|
9
9
|
|
10
10
|
class ClientTest < StrategyTestCase
|
11
11
|
test 'has correct Facebook site' do
|
12
|
-
assert_equal 'https://graph.facebook.com', strategy.client.site
|
12
|
+
assert_equal 'https://graph.facebook.com/v2.6', strategy.client.site
|
13
13
|
end
|
14
14
|
|
15
15
|
test 'has correct authorize url' do
|
16
|
-
assert_equal 'https://www.facebook.com/dialog/oauth', strategy.client.options[:authorize_url]
|
16
|
+
assert_equal 'https://www.facebook.com/v2.6/dialog/oauth', strategy.client.options[:authorize_url]
|
17
17
|
end
|
18
18
|
|
19
19
|
test 'has correct token url with versioning' do
|
20
|
-
@options = {:
|
20
|
+
@options = {client_options: {site: 'https://graph.facebook.net/v2.2'}}
|
21
21
|
assert_equal 'oauth/access_token', strategy.client.options[:token_url]
|
22
22
|
assert_equal 'https://graph.facebook.net/v2.2/oauth/access_token', strategy.client.token_url
|
23
23
|
end
|
@@ -33,7 +33,7 @@ class CallbackUrlTest < StrategyTestCase
|
|
33
33
|
end
|
34
34
|
|
35
35
|
test "returns path from callback_path option (omitting querystring)" do
|
36
|
-
@options = { :
|
36
|
+
@options = { callback_path: "/auth/FB/done"}
|
37
37
|
url_base = 'http://auth.request.com'
|
38
38
|
@request.stubs(:url).returns("#{url_base}/page/path")
|
39
39
|
strategy.stubs(:script_name).returns('') # as not to depend on Rack env
|
@@ -43,7 +43,7 @@ class CallbackUrlTest < StrategyTestCase
|
|
43
43
|
|
44
44
|
test "returns url from callback_url option" do
|
45
45
|
url = 'https://auth.myapp.com/auth/fb/callback'
|
46
|
-
@options = { :
|
46
|
+
@options = { callback_url: url }
|
47
47
|
assert_equal url, strategy.callback_url
|
48
48
|
end
|
49
49
|
end
|
@@ -73,12 +73,6 @@ class AuthorizeParamsTest < StrategyTestCase
|
|
73
73
|
end
|
74
74
|
end
|
75
75
|
|
76
|
-
class TokeParamsTest < StrategyTestCase
|
77
|
-
test 'has correct parse strategy' do
|
78
|
-
assert_equal :query, strategy.token_params[:parse]
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
76
|
class AccessTokenOptionsTest < StrategyTestCase
|
83
77
|
test 'has correct param name by default' do
|
84
78
|
assert_equal 'access_token', strategy.access_token_options[:param_name]
|
@@ -102,40 +96,40 @@ end
|
|
102
96
|
|
103
97
|
class InfoTest < StrategyTestCase
|
104
98
|
test 'returns the secure facebook avatar url when `secure_image_url` option is specified' do
|
105
|
-
@options = { :
|
99
|
+
@options = { secure_image_url: true }
|
106
100
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
107
101
|
strategy.stubs(:raw_info).returns(raw_info)
|
108
|
-
assert_equal 'https://graph.facebook.com/321/picture', strategy.info['image']
|
102
|
+
assert_equal 'https://graph.facebook.com/v2.6/321/picture', strategy.info['image']
|
109
103
|
end
|
110
104
|
|
111
105
|
test 'returns the image_url based of the client site' do
|
112
|
-
@options = { :
|
106
|
+
@options = { secure_image_url: true, client_options: {site: "https://blah.facebook.com/v2.2"}}
|
113
107
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
114
108
|
strategy.stubs(:raw_info).returns(raw_info)
|
115
109
|
assert_equal 'https://blah.facebook.com/v2.2/321/picture', strategy.info['image']
|
116
110
|
end
|
117
111
|
|
118
112
|
test 'returns the image with size specified in the `image_size` option' do
|
119
|
-
@options = { :
|
113
|
+
@options = { image_size: 'normal' }
|
120
114
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
121
115
|
strategy.stubs(:raw_info).returns(raw_info)
|
122
|
-
assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
|
116
|
+
assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image']
|
123
117
|
end
|
124
118
|
|
125
119
|
test 'returns the image with size specified as a symbol in the `image_size` option' do
|
126
|
-
@options = { :
|
120
|
+
@options = { image_size: :normal }
|
127
121
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
128
122
|
strategy.stubs(:raw_info).returns(raw_info)
|
129
|
-
assert_equal 'http://graph.facebook.com/321/picture?type=normal', strategy.info['image']
|
123
|
+
assert_equal 'http://graph.facebook.com/v2.6/321/picture?type=normal', strategy.info['image']
|
130
124
|
end
|
131
125
|
|
132
126
|
test 'returns the image with width and height specified in the `image_size` option' do
|
133
|
-
@options = { :
|
127
|
+
@options = { image_size: { width: 123, height: 987 } }
|
134
128
|
raw_info = { 'name' => 'Fred Smith', 'id' => '321' }
|
135
129
|
strategy.stubs(:raw_info).returns(raw_info)
|
136
130
|
assert_match 'width=123', strategy.info['image']
|
137
131
|
assert_match 'height=987', strategy.info['image']
|
138
|
-
assert_match 'http://graph.facebook.com/321/picture?', strategy.info['image']
|
132
|
+
assert_match 'http://graph.facebook.com/v2.6/321/picture?', strategy.info['image']
|
139
133
|
end
|
140
134
|
end
|
141
135
|
|
@@ -182,7 +176,7 @@ class InfoTestOptionalDataPresent < StrategyTestCase
|
|
182
176
|
|
183
177
|
test 'returns the facebook avatar url' do
|
184
178
|
@raw_info['id'] = '321'
|
185
|
-
assert_equal 'http://graph.facebook.com/321/picture', strategy.info['image']
|
179
|
+
assert_equal 'http://graph.facebook.com/v2.6/321/picture', strategy.info['image']
|
186
180
|
end
|
187
181
|
|
188
182
|
test 'returns the Facebook link as the Facebook url' do
|
@@ -261,39 +255,39 @@ class RawInfoTest < StrategyTestCase
|
|
261
255
|
super
|
262
256
|
@access_token = stub('OAuth2::AccessToken')
|
263
257
|
@appsecret_proof = 'appsecret_proof'
|
264
|
-
@options = {:
|
258
|
+
@options = {appsecret_proof: @appsecret_proof, fields: 'name,email'}
|
265
259
|
end
|
266
260
|
|
267
|
-
test 'performs a GET to https://graph.facebook.com/me' do
|
261
|
+
test 'performs a GET to https://graph.facebook.com/v2.6/me' do
|
268
262
|
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
269
263
|
strategy.stubs(:access_token).returns(@access_token)
|
270
|
-
params = {:
|
264
|
+
params = {params: @options}
|
271
265
|
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
|
272
266
|
strategy.raw_info
|
273
267
|
end
|
274
268
|
|
275
|
-
test 'performs a GET to https://graph.facebook.com/me with locale' do
|
276
|
-
@options.merge!({ :
|
269
|
+
test 'performs a GET to https://graph.facebook.com/v2.6/me with locale' do
|
270
|
+
@options.merge!({ locale: 'cs_CZ' })
|
277
271
|
strategy.stubs(:access_token).returns(@access_token)
|
278
272
|
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
279
|
-
params = {:
|
273
|
+
params = {params: @options}
|
280
274
|
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
|
281
275
|
strategy.raw_info
|
282
276
|
end
|
283
277
|
|
284
|
-
test 'performs a GET to https://graph.facebook.com/me with info_fields' do
|
285
|
-
@options.merge!({:
|
278
|
+
test 'performs a GET to https://graph.facebook.com/v2.6/me with info_fields' do
|
279
|
+
@options.merge!({info_fields: 'about'})
|
286
280
|
strategy.stubs(:access_token).returns(@access_token)
|
287
281
|
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
288
|
-
params = {:
|
282
|
+
params = {params: {appsecret_proof: @appsecret_proof, fields: 'about'}}
|
289
283
|
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
|
290
284
|
strategy.raw_info
|
291
285
|
end
|
292
286
|
|
293
|
-
test 'performs a GET to https://graph.facebook.com/me with default info_fields' do
|
287
|
+
test 'performs a GET to https://graph.facebook.com/v2.6/me with default info_fields' do
|
294
288
|
strategy.stubs(:access_token).returns(@access_token)
|
295
289
|
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
296
|
-
params = {:
|
290
|
+
params = {params: {appsecret_proof: @appsecret_proof, fields: 'name,email'}}
|
297
291
|
@access_token.expects(:get).with('me', params).returns(stub_everything('OAuth2::Response'))
|
298
292
|
strategy.raw_info
|
299
293
|
end
|
@@ -306,7 +300,7 @@ class RawInfoTest < StrategyTestCase
|
|
306
300
|
raw_response.stubs(:status).returns(200)
|
307
301
|
raw_response.stubs(:headers).returns({'Content-Type' => 'application/json' })
|
308
302
|
oauth2_response = OAuth2::Response.new(raw_response)
|
309
|
-
params = {:
|
303
|
+
params = {params: @options}
|
310
304
|
@access_token.stubs(:get).with('me', params).returns(oauth2_response)
|
311
305
|
assert_kind_of Hash, strategy.raw_info
|
312
306
|
assert_equal 'thar', strategy.raw_info['ohai']
|
@@ -315,16 +309,16 @@ class RawInfoTest < StrategyTestCase
|
|
315
309
|
test 'returns an empty hash when the response is false' do
|
316
310
|
strategy.stubs(:access_token).returns(@access_token)
|
317
311
|
strategy.stubs(:appsecret_proof).returns(@appsecret_proof)
|
318
|
-
oauth2_response = stub('OAuth2::Response', :
|
319
|
-
params = {:
|
312
|
+
oauth2_response = stub('OAuth2::Response', parsed: false)
|
313
|
+
params = {params: @options}
|
320
314
|
@access_token.stubs(:get).with('me', params).returns(oauth2_response)
|
321
315
|
assert_kind_of Hash, strategy.raw_info
|
322
316
|
assert_equal({}, strategy.raw_info)
|
323
317
|
end
|
324
318
|
|
325
319
|
test 'should not include raw_info in extras hash when skip_info is specified' do
|
326
|
-
@options = { :
|
327
|
-
strategy.stubs(:raw_info).returns({:
|
320
|
+
@options = { skip_info: true }
|
321
|
+
strategy.stubs(:raw_info).returns({foo: 'bar' })
|
328
322
|
refute_has_key 'raw_info', strategy.extra
|
329
323
|
end
|
330
324
|
end
|
@@ -13,7 +13,7 @@ module OAuth2StrategyTests
|
|
13
13
|
extend BlockTestHelper
|
14
14
|
|
15
15
|
test 'should be initialized with symbolized client_options' do
|
16
|
-
@options = { :
|
16
|
+
@options = { client_options: { 'authorize_url' => 'https://example.com' } }
|
17
17
|
assert_equal 'https://example.com', strategy.client.options[:authorize_url]
|
18
18
|
end
|
19
19
|
end
|
@@ -22,19 +22,19 @@ module OAuth2StrategyTests
|
|
22
22
|
extend BlockTestHelper
|
23
23
|
|
24
24
|
test 'should include any authorize params passed in the :authorize_params option' do
|
25
|
-
@options = { :
|
25
|
+
@options = { authorize_params: { foo: 'bar', baz: 'zip' } }
|
26
26
|
assert_equal 'bar', strategy.authorize_params['foo']
|
27
27
|
assert_equal 'zip', strategy.authorize_params['baz']
|
28
28
|
end
|
29
29
|
|
30
30
|
test 'should include top-level options that are marked as :authorize_options' do
|
31
|
-
@options = { :
|
31
|
+
@options = { authorize_options: [:scope, :foo], scope: 'bar', foo: 'baz' }
|
32
32
|
assert_equal 'bar', strategy.authorize_params['scope']
|
33
33
|
assert_equal 'baz', strategy.authorize_params['foo']
|
34
34
|
end
|
35
35
|
|
36
36
|
test 'should exclude top-level options that are not passed' do
|
37
|
-
@options = { :
|
37
|
+
@options = { authorize_options: [:bar] }
|
38
38
|
refute_has_key :bar, strategy.authorize_params
|
39
39
|
refute_has_key 'bar', strategy.authorize_params
|
40
40
|
end
|
@@ -51,7 +51,7 @@ module OAuth2StrategyTests
|
|
51
51
|
end
|
52
52
|
|
53
53
|
test 'should not store state in the session when present in authorize params vs. a random one' do
|
54
|
-
@options = { :
|
54
|
+
@options = { authorize_params: { state: 'bar' } }
|
55
55
|
refute_empty strategy.authorize_params['state']
|
56
56
|
refute_equal 'bar', strategy.authorize_params[:state]
|
57
57
|
refute_empty strategy.session['omniauth.state']
|
@@ -71,13 +71,13 @@ module OAuth2StrategyTests
|
|
71
71
|
extend BlockTestHelper
|
72
72
|
|
73
73
|
test 'should include any authorize params passed in the :token_params option' do
|
74
|
-
@options = { :
|
74
|
+
@options = { token_params: { foo: 'bar', baz: 'zip' } }
|
75
75
|
assert_equal 'bar', strategy.token_params['foo']
|
76
76
|
assert_equal 'zip', strategy.token_params['baz']
|
77
77
|
end
|
78
78
|
|
79
79
|
test 'should include top-level options that are marked as :token_options' do
|
80
|
-
@options = { :
|
80
|
+
@options = { token_options: [:scope, :foo], scope: 'bar', foo: 'baz' }
|
81
81
|
assert_equal 'bar', strategy.token_params['scope']
|
82
82
|
assert_equal 'baz', strategy.token_params['foo']
|
83
83
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: omniauth-facebook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 4.0.0.rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mark Dodwell
|
@@ -9,62 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: omniauth-oauth2
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '1.2'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '1.2'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: minitest
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :development
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: mocha
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: rake
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- -
|
60
|
+
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- -
|
67
|
+
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '0'
|
70
70
|
description:
|
@@ -75,8 +75,8 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- .gitignore
|
79
|
-
- .travis.yml
|
78
|
+
- ".gitignore"
|
79
|
+
- ".travis.yml"
|
80
80
|
- CHANGELOG.md
|
81
81
|
- Gemfile
|
82
82
|
- README.md
|
@@ -107,17 +107,17 @@ require_paths:
|
|
107
107
|
- lib
|
108
108
|
required_ruby_version: !ruby/object:Gem::Requirement
|
109
109
|
requirements:
|
110
|
-
- -
|
110
|
+
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
112
|
version: '0'
|
113
113
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ">"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: 1.3.1
|
118
118
|
requirements: []
|
119
119
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.
|
120
|
+
rubygems_version: 2.4.5.1
|
121
121
|
signing_key:
|
122
122
|
specification_version: 4
|
123
123
|
summary: Facebook OAuth2 Strategy for OmniAuth
|