omniauth_llx 0.0.12 → 0.0.13
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.
- metadata +6 -136
- data/MIT-LICENSE +0 -20
- data/README.rdoc +0 -3
- data/Rakefile +0 -32
- data/lib/example/Gemfile +0 -5
- data/lib/example/Gemfile.lock +0 -58
- data/lib/example/app.rb +0 -93
- data/lib/example/config.ru +0 -11
- data/lib/omniauth_llx.rb +0 -1
- data/lib/omniauth_llx/llx.rb +0 -2
- data/lib/omniauth_llx/llx/version.rb +0 -5
- data/lib/omniauth_llx/strategies/llx.rb +0 -209
- data/lib/tasks/omniauth_llx_tasks.rake +0 -4
- data/test/dummy/README.rdoc +0 -28
- data/test/dummy/Rakefile +0 -6
- data/test/dummy/app/assets/javascripts/application.js +0 -13
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/dummy/app/controllers/application_controller.rb +0 -5
- data/test/dummy/app/helpers/application_helper.rb +0 -2
- data/test/dummy/app/views/layouts/application.html.erb +0 -14
- data/test/dummy/bin/bundle +0 -3
- data/test/dummy/bin/rails +0 -4
- data/test/dummy/bin/rake +0 -4
- data/test/dummy/config.ru +0 -4
- data/test/dummy/config/application.rb +0 -23
- data/test/dummy/config/boot.rb +0 -5
- data/test/dummy/config/database.yml +0 -25
- data/test/dummy/config/environment.rb +0 -5
- data/test/dummy/config/environments/development.rb +0 -37
- data/test/dummy/config/environments/production.rb +0 -82
- data/test/dummy/config/environments/test.rb +0 -39
- data/test/dummy/config/initializers/assets.rb +0 -8
- data/test/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/test/dummy/config/initializers/inflections.rb +0 -16
- data/test/dummy/config/initializers/mime_types.rb +0 -4
- data/test/dummy/config/initializers/session_store.rb +0 -3
- data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/test/dummy/config/locales/en.yml +0 -23
- data/test/dummy/config/routes.rb +0 -56
- data/test/dummy/config/secrets.yml +0 -22
- data/test/dummy/public/404.html +0 -67
- data/test/dummy/public/422.html +0 -67
- data/test/dummy/public/500.html +0 -66
- data/test/dummy/public/favicon.ico +0 -0
- data/test/omniauth_llx_test.rb +0 -7
- data/test/test_helper.rb +0 -15
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: omniauth_llx
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.13
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -11,38 +11,6 @@ bindir: bin
|
|
|
11
11
|
cert_chain: []
|
|
12
12
|
date: 2014-09-10 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
|
-
- !ruby/object:Gem::Dependency
|
|
15
|
-
name: rails
|
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
|
17
|
-
none: false
|
|
18
|
-
requirements:
|
|
19
|
-
- - ~>
|
|
20
|
-
- !ruby/object:Gem::Version
|
|
21
|
-
version: 4.1.0
|
|
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: 4.1.0
|
|
30
|
-
- !ruby/object:Gem::Dependency
|
|
31
|
-
name: mysql2
|
|
32
|
-
requirement: !ruby/object:Gem::Requirement
|
|
33
|
-
none: false
|
|
34
|
-
requirements:
|
|
35
|
-
- - ! '>='
|
|
36
|
-
- !ruby/object:Gem::Version
|
|
37
|
-
version: '0'
|
|
38
|
-
type: :development
|
|
39
|
-
prerelease: false
|
|
40
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
41
|
-
none: false
|
|
42
|
-
requirements:
|
|
43
|
-
- - ! '>='
|
|
44
|
-
- !ruby/object:Gem::Version
|
|
45
|
-
version: '0'
|
|
46
14
|
- !ruby/object:Gem::Dependency
|
|
47
15
|
name: omniauth-oauth2
|
|
48
16
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -60,29 +28,13 @@ dependencies:
|
|
|
60
28
|
- !ruby/object:Gem::Version
|
|
61
29
|
version: '1.2'
|
|
62
30
|
- !ruby/object:Gem::Dependency
|
|
63
|
-
name:
|
|
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: mocha
|
|
31
|
+
name: rspec
|
|
80
32
|
requirement: !ruby/object:Gem::Requirement
|
|
81
33
|
none: false
|
|
82
34
|
requirements:
|
|
83
35
|
- - ! '>='
|
|
84
36
|
- !ruby/object:Gem::Version
|
|
85
|
-
version:
|
|
37
|
+
version: 2.14.0
|
|
86
38
|
type: :development
|
|
87
39
|
prerelease: false
|
|
88
40
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -90,7 +42,7 @@ dependencies:
|
|
|
90
42
|
requirements:
|
|
91
43
|
- - ! '>='
|
|
92
44
|
- !ruby/object:Gem::Version
|
|
93
|
-
version:
|
|
45
|
+
version: 2.14.0
|
|
94
46
|
- !ruby/object:Gem::Dependency
|
|
95
47
|
name: rake
|
|
96
48
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -112,54 +64,7 @@ email: sozai_3783@hotmail.com
|
|
|
112
64
|
executables: []
|
|
113
65
|
extensions: []
|
|
114
66
|
extra_rdoc_files: []
|
|
115
|
-
files:
|
|
116
|
-
- lib/example/app.rb
|
|
117
|
-
- lib/example/config.ru
|
|
118
|
-
- lib/example/Gemfile
|
|
119
|
-
- lib/example/Gemfile.lock
|
|
120
|
-
- lib/omniauth_llx/llx/version.rb
|
|
121
|
-
- lib/omniauth_llx/llx.rb
|
|
122
|
-
- lib/omniauth_llx/strategies/llx.rb
|
|
123
|
-
- lib/omniauth_llx.rb
|
|
124
|
-
- lib/tasks/omniauth_llx_tasks.rake
|
|
125
|
-
- MIT-LICENSE
|
|
126
|
-
- Rakefile
|
|
127
|
-
- README.rdoc
|
|
128
|
-
- test/dummy/app/assets/javascripts/application.js
|
|
129
|
-
- test/dummy/app/assets/stylesheets/application.css
|
|
130
|
-
- test/dummy/app/controllers/application_controller.rb
|
|
131
|
-
- test/dummy/app/helpers/application_helper.rb
|
|
132
|
-
- test/dummy/app/views/layouts/application.html.erb
|
|
133
|
-
- test/dummy/bin/bundle
|
|
134
|
-
- test/dummy/bin/rails
|
|
135
|
-
- test/dummy/bin/rake
|
|
136
|
-
- test/dummy/config/application.rb
|
|
137
|
-
- test/dummy/config/boot.rb
|
|
138
|
-
- test/dummy/config/database.yml
|
|
139
|
-
- test/dummy/config/environment.rb
|
|
140
|
-
- test/dummy/config/environments/development.rb
|
|
141
|
-
- test/dummy/config/environments/production.rb
|
|
142
|
-
- test/dummy/config/environments/test.rb
|
|
143
|
-
- test/dummy/config/initializers/assets.rb
|
|
144
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
145
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
|
146
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
|
147
|
-
- test/dummy/config/initializers/inflections.rb
|
|
148
|
-
- test/dummy/config/initializers/mime_types.rb
|
|
149
|
-
- test/dummy/config/initializers/session_store.rb
|
|
150
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
|
151
|
-
- test/dummy/config/locales/en.yml
|
|
152
|
-
- test/dummy/config/routes.rb
|
|
153
|
-
- test/dummy/config/secrets.yml
|
|
154
|
-
- test/dummy/config.ru
|
|
155
|
-
- test/dummy/public/404.html
|
|
156
|
-
- test/dummy/public/422.html
|
|
157
|
-
- test/dummy/public/500.html
|
|
158
|
-
- test/dummy/public/favicon.ico
|
|
159
|
-
- test/dummy/Rakefile
|
|
160
|
-
- test/dummy/README.rdoc
|
|
161
|
-
- test/omniauth_llx_test.rb
|
|
162
|
-
- test/test_helper.rb
|
|
67
|
+
files: []
|
|
163
68
|
homepage:
|
|
164
69
|
licenses:
|
|
165
70
|
- MIT
|
|
@@ -185,39 +90,4 @@ rubygems_version: 1.8.28
|
|
|
185
90
|
signing_key:
|
|
186
91
|
specification_version: 3
|
|
187
92
|
summary: develop test create gem
|
|
188
|
-
test_files:
|
|
189
|
-
- test/dummy/app/assets/javascripts/application.js
|
|
190
|
-
- test/dummy/app/assets/stylesheets/application.css
|
|
191
|
-
- test/dummy/app/controllers/application_controller.rb
|
|
192
|
-
- test/dummy/app/helpers/application_helper.rb
|
|
193
|
-
- test/dummy/app/views/layouts/application.html.erb
|
|
194
|
-
- test/dummy/bin/bundle
|
|
195
|
-
- test/dummy/bin/rails
|
|
196
|
-
- test/dummy/bin/rake
|
|
197
|
-
- test/dummy/config/application.rb
|
|
198
|
-
- test/dummy/config/boot.rb
|
|
199
|
-
- test/dummy/config/database.yml
|
|
200
|
-
- test/dummy/config/environment.rb
|
|
201
|
-
- test/dummy/config/environments/development.rb
|
|
202
|
-
- test/dummy/config/environments/production.rb
|
|
203
|
-
- test/dummy/config/environments/test.rb
|
|
204
|
-
- test/dummy/config/initializers/assets.rb
|
|
205
|
-
- test/dummy/config/initializers/backtrace_silencers.rb
|
|
206
|
-
- test/dummy/config/initializers/cookies_serializer.rb
|
|
207
|
-
- test/dummy/config/initializers/filter_parameter_logging.rb
|
|
208
|
-
- test/dummy/config/initializers/inflections.rb
|
|
209
|
-
- test/dummy/config/initializers/mime_types.rb
|
|
210
|
-
- test/dummy/config/initializers/session_store.rb
|
|
211
|
-
- test/dummy/config/initializers/wrap_parameters.rb
|
|
212
|
-
- test/dummy/config/locales/en.yml
|
|
213
|
-
- test/dummy/config/routes.rb
|
|
214
|
-
- test/dummy/config/secrets.yml
|
|
215
|
-
- test/dummy/config.ru
|
|
216
|
-
- test/dummy/public/404.html
|
|
217
|
-
- test/dummy/public/422.html
|
|
218
|
-
- test/dummy/public/500.html
|
|
219
|
-
- test/dummy/public/favicon.ico
|
|
220
|
-
- test/dummy/Rakefile
|
|
221
|
-
- test/dummy/README.rdoc
|
|
222
|
-
- test/omniauth_llx_test.rb
|
|
223
|
-
- test/test_helper.rb
|
|
93
|
+
test_files: []
|
data/MIT-LICENSE
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
Copyright 2014 YOURNAME
|
|
2
|
-
|
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
-
a copy of this software and associated documentation files (the
|
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
-
the following conditions:
|
|
10
|
-
|
|
11
|
-
The above copyright notice and this permission notice shall be
|
|
12
|
-
included in all copies or substantial portions of the Software.
|
|
13
|
-
|
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
DELETED
data/Rakefile
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
begin
|
|
2
|
-
require 'bundler/setup'
|
|
3
|
-
rescue LoadError
|
|
4
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
-
end
|
|
6
|
-
|
|
7
|
-
require 'rdoc/task'
|
|
8
|
-
|
|
9
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
-
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
-
rdoc.title = 'OmniauthLlx'
|
|
12
|
-
rdoc.options << '--line-numbers'
|
|
13
|
-
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
Bundler::GemHelper.install_tasks
|
|
21
|
-
|
|
22
|
-
require 'rake/testtask'
|
|
23
|
-
|
|
24
|
-
Rake::TestTask.new(:test) do |t|
|
|
25
|
-
t.libs << 'lib'
|
|
26
|
-
t.libs << 'test'
|
|
27
|
-
t.pattern = 'test/**/*_test.rb'
|
|
28
|
-
t.verbose = false
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
task default: :test
|
data/lib/example/Gemfile
DELETED
data/lib/example/Gemfile.lock
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
PATH
|
|
2
|
-
remote: ../
|
|
3
|
-
specs:
|
|
4
|
-
omniauth-facebook (2.0.0)
|
|
5
|
-
omniauth-oauth2 (~> 1.2)
|
|
6
|
-
|
|
7
|
-
GEM
|
|
8
|
-
remote: https://rubygems.org/
|
|
9
|
-
specs:
|
|
10
|
-
backports (3.3.5)
|
|
11
|
-
faraday (0.9.0)
|
|
12
|
-
multipart-post (>= 1.2, < 3)
|
|
13
|
-
hashie (3.2.0)
|
|
14
|
-
jwt (1.0.0)
|
|
15
|
-
multi_json (1.8.2)
|
|
16
|
-
multi_xml (0.5.5)
|
|
17
|
-
multipart-post (2.0.0)
|
|
18
|
-
oauth2 (1.0.0)
|
|
19
|
-
faraday (>= 0.8, < 0.10)
|
|
20
|
-
jwt (~> 1.0)
|
|
21
|
-
multi_json (~> 1.3)
|
|
22
|
-
multi_xml (~> 0.5)
|
|
23
|
-
rack (~> 1.2)
|
|
24
|
-
omniauth (1.2.2)
|
|
25
|
-
hashie (>= 1.2, < 4)
|
|
26
|
-
rack (~> 1.0)
|
|
27
|
-
omniauth-oauth2 (1.2.0)
|
|
28
|
-
faraday (>= 0.8, < 0.10)
|
|
29
|
-
multi_json (~> 1.3)
|
|
30
|
-
oauth2 (~> 1.0)
|
|
31
|
-
omniauth (~> 1.2)
|
|
32
|
-
rack (1.5.2)
|
|
33
|
-
rack-protection (1.5.1)
|
|
34
|
-
rack
|
|
35
|
-
rack-test (0.6.2)
|
|
36
|
-
rack (>= 1.0)
|
|
37
|
-
sinatra (1.4.4)
|
|
38
|
-
rack (~> 1.4)
|
|
39
|
-
rack-protection (~> 1.4)
|
|
40
|
-
tilt (~> 1.3, >= 1.3.4)
|
|
41
|
-
sinatra-contrib (1.4.2)
|
|
42
|
-
backports (>= 2.0)
|
|
43
|
-
multi_json
|
|
44
|
-
rack-protection
|
|
45
|
-
rack-test
|
|
46
|
-
sinatra (~> 1.4.0)
|
|
47
|
-
tilt (~> 1.3)
|
|
48
|
-
sinatra-reloader (1.0)
|
|
49
|
-
sinatra-contrib
|
|
50
|
-
tilt (1.4.1)
|
|
51
|
-
|
|
52
|
-
PLATFORMS
|
|
53
|
-
ruby
|
|
54
|
-
|
|
55
|
-
DEPENDENCIES
|
|
56
|
-
omniauth-facebook!
|
|
57
|
-
sinatra
|
|
58
|
-
sinatra-reloader
|
data/lib/example/app.rb
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
require 'sinatra'
|
|
2
|
-
require "sinatra/reloader"
|
|
3
|
-
require 'yaml'
|
|
4
|
-
|
|
5
|
-
# configure sinatra
|
|
6
|
-
set :run, false
|
|
7
|
-
set :raise_errors, true
|
|
8
|
-
|
|
9
|
-
# setup logging to file
|
|
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
|
|
17
|
-
get '/server-side' do
|
|
18
|
-
# NOTE: You would just hit this endpoint directly from the browser in a real app. The redirect is just here to
|
|
19
|
-
# explicit declare this server-side flow.
|
|
20
|
-
redirect 'http://auth.cibplus.com'
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# client-side flow
|
|
24
|
-
get '/client-side' do
|
|
25
|
-
content_type 'text/html'
|
|
26
|
-
# NOTE: When you enable cookie below in the FB.init call the GET request in the FB.login callback will send a signed
|
|
27
|
-
# request in a cookie back the OmniAuth callback which will parse out the authorization code and obtain an
|
|
28
|
-
# access_token with it.
|
|
29
|
-
<<-END
|
|
30
|
-
<html>
|
|
31
|
-
<head>
|
|
32
|
-
<title>Client-side Flow Example</title>
|
|
33
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js" type="text/javascript"></script>
|
|
34
|
-
</head>
|
|
35
|
-
<body>
|
|
36
|
-
<div id="fb-root"></div>
|
|
37
|
-
|
|
38
|
-
<script type="text/javascript">
|
|
39
|
-
window.fbAsyncInit = function() {
|
|
40
|
-
FB.init({
|
|
41
|
-
appId : '#{ENV['APP_ID']}',
|
|
42
|
-
status : true, // check login status
|
|
43
|
-
cookie : true, // enable cookies to allow the server to access the session
|
|
44
|
-
xfbml : true // parse XFBML
|
|
45
|
-
});
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
(function(d) {
|
|
49
|
-
var js, id = 'facebook-jssdk'; if (d.getElementById(id)) {return;}
|
|
50
|
-
js = d.createElement('script'); js.id = id; js.async = true;
|
|
51
|
-
js.src = "//connect.facebook.net/en_US/all.js";
|
|
52
|
-
d.getElementsByTagName('head')[0].appendChild(js);
|
|
53
|
-
}(document));
|
|
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
|
-
});
|
|
73
|
-
</script>
|
|
74
|
-
|
|
75
|
-
<p id="connect">
|
|
76
|
-
<a href="#">Connect to FB!</a>
|
|
77
|
-
</p>
|
|
78
|
-
|
|
79
|
-
<p id="results" />
|
|
80
|
-
</body>
|
|
81
|
-
</html>
|
|
82
|
-
END
|
|
83
|
-
end
|
|
84
|
-
|
|
85
|
-
get '/auth/:provider/callback' do
|
|
86
|
-
content_type 'application/json'
|
|
87
|
-
MultiJson.encode(request.env)
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
get '/auth/failure' do
|
|
91
|
-
content_type 'application/json'
|
|
92
|
-
MultiJson.encode(request.env)
|
|
93
|
-
end
|
data/lib/example/config.ru
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
require 'bundler/setup'
|
|
2
|
-
require 'omniauth-facebook'
|
|
3
|
-
require './app.rb'
|
|
4
|
-
|
|
5
|
-
use Rack::Session::Cookie, :secret => 'abc123'
|
|
6
|
-
|
|
7
|
-
use OmniAuth::Builder do
|
|
8
|
-
provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], :scope => 'email,read_stream'
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
run Sinatra::Application
|
data/lib/omniauth_llx.rb
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
require 'omniauth_llx/llx'
|
data/lib/omniauth_llx/llx.rb
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
require 'omniauth/strategies/oauth2'
|
|
2
|
-
require 'base64'
|
|
3
|
-
require 'openssl'
|
|
4
|
-
require 'rack/utils'
|
|
5
|
-
require 'uri'
|
|
6
|
-
|
|
7
|
-
module OmniAuthLlx
|
|
8
|
-
module Strategies
|
|
9
|
-
|
|
10
|
-
class Llx < OmniAuth::Strategies::OAuth2
|
|
11
|
-
class NoAuthorizationCodeError < StandardError; end
|
|
12
|
-
class UnknownSignatureAlgorithmError < NotImplementedError; end
|
|
13
|
-
|
|
14
|
-
DEFAULT_SCOPE = 'email'
|
|
15
|
-
|
|
16
|
-
option :client_options, {
|
|
17
|
-
:site => 'http://auth.cibplus.com',
|
|
18
|
-
:authorize_url => "http://auth.cibplus.com/oauth/authorize",
|
|
19
|
-
:token_url => '/oauth/token'
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
option :token_params, {
|
|
23
|
-
:parse => :query
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
option :access_token_options, {
|
|
27
|
-
:header_format => 'OAuth %s',
|
|
28
|
-
:param_name => 'access_token'
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
option :authorize_options, [:scope, :display, :auth_type]
|
|
32
|
-
|
|
33
|
-
uid { raw_info['id'] }
|
|
34
|
-
|
|
35
|
-
info do
|
|
36
|
-
prune!({
|
|
37
|
-
'nickname' => raw_info['username'],
|
|
38
|
-
'email' => raw_info['email'],
|
|
39
|
-
'name' => raw_info['name'],
|
|
40
|
-
'first_name' => raw_info['first_name'],
|
|
41
|
-
'last_name' => raw_info['last_name'],
|
|
42
|
-
'image' => image_url(uid, options),
|
|
43
|
-
'description' => raw_info['bio'],
|
|
44
|
-
'urls' => {
|
|
45
|
-
'Llx' => raw_info['link'],
|
|
46
|
-
'Website' => raw_info['website']
|
|
47
|
-
},
|
|
48
|
-
'location' => (raw_info['location'] || {})['name'],
|
|
49
|
-
'verified' => raw_info['verified']
|
|
50
|
-
})
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
extra do
|
|
54
|
-
hash = {}
|
|
55
|
-
hash['raw_info'] = raw_info unless skip_info?
|
|
56
|
-
prune! hash
|
|
57
|
-
end
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def raw_info
|
|
62
|
-
@raw_info ||= access_token.get('/me', info_options).parsed || {}
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
def info_options
|
|
66
|
-
params = {:appsecret_proof => appsecret_proof}
|
|
67
|
-
params.merge!({:fields => options[:info_fields]}) if options[:info_fields]
|
|
68
|
-
params.merge!({:locale => options[:locale]}) if options[:locale]
|
|
69
|
-
|
|
70
|
-
{ :params => params }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
def callback_phase
|
|
74
|
-
with_authorization_code! do
|
|
75
|
-
super
|
|
76
|
-
end
|
|
77
|
-
rescue NoAuthorizationCodeError => e
|
|
78
|
-
fail!(:no_authorization_code, e)
|
|
79
|
-
rescue UnknownSignatureAlgorithmError => e
|
|
80
|
-
fail!(:unknown_signature_algoruthm, e)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# NOTE If we're using code from the signed request then FB sets the redirect_uri to '' during the authorize
|
|
84
|
-
# phase and it must match during the access_token phase:
|
|
85
|
-
# https://github.com/facebook/facebook-php-sdk/blob/master/src/base_facebook.php#L477
|
|
86
|
-
def callback_url
|
|
87
|
-
if @authorization_code_from_signed_request_in_cookie
|
|
88
|
-
''
|
|
89
|
-
else
|
|
90
|
-
options[:callback_url] || super
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def access_token_options
|
|
95
|
-
options.access_token_options.inject({}) { |h,(k,v)| h[k.to_sym] = v; h }
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# You can pass +display+, +scope+, or +auth_type+ params to the auth request, if you need to set them dynamically.
|
|
99
|
-
# You can also set these options in the OmniAuth config :authorize_params option.
|
|
100
|
-
#
|
|
101
|
-
# For example: /auth/facebook?display=popup
|
|
102
|
-
def authorize_params
|
|
103
|
-
super.tap do |params|
|
|
104
|
-
%w[display scope auth_type].each do |v|
|
|
105
|
-
if request.params[v]
|
|
106
|
-
params[v.to_sym] = request.params[v]
|
|
107
|
-
end
|
|
108
|
-
end
|
|
109
|
-
|
|
110
|
-
params[:scope] ||= DEFAULT_SCOPE
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
protected
|
|
115
|
-
|
|
116
|
-
def build_access_token
|
|
117
|
-
super.tap do |token|
|
|
118
|
-
token.options.merge!(access_token_options)
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
private
|
|
123
|
-
|
|
124
|
-
def signed_request_from_cookie
|
|
125
|
-
@signed_request_from_cookie ||= raw_signed_request_from_cookie && parse_signed_request(raw_signed_request_from_cookie)
|
|
126
|
-
end
|
|
127
|
-
|
|
128
|
-
def raw_signed_request_from_cookie
|
|
129
|
-
request.cookies["fbsr_#{client.id}"]
|
|
130
|
-
end
|
|
131
|
-
|
|
132
|
-
# Picks the authorization code in order, from:
|
|
133
|
-
#
|
|
134
|
-
# 1. The request 'code' param (manual callback from standard server-side flow)
|
|
135
|
-
# 2. A signed request from cookie (passed from the client during the client-side flow)
|
|
136
|
-
def with_authorization_code!
|
|
137
|
-
if request.params.key?('code')
|
|
138
|
-
yield
|
|
139
|
-
elsif code_from_signed_request = signed_request_from_cookie && signed_request_from_cookie['code']
|
|
140
|
-
request.params['code'] = code_from_signed_request
|
|
141
|
-
@authorization_code_from_signed_request_in_cookie = true
|
|
142
|
-
# NOTE The code from the signed fbsr_XXX cookie is set by the FB JS SDK will confirm that the identity of the
|
|
143
|
-
# user contained in the signed request matches the user loading the app.
|
|
144
|
-
original_provider_ignores_state = options.provider_ignores_state
|
|
145
|
-
options.provider_ignores_state = true
|
|
146
|
-
begin
|
|
147
|
-
yield
|
|
148
|
-
ensure
|
|
149
|
-
request.params.delete('code')
|
|
150
|
-
@authorization_code_from_signed_request_in_cookie = false
|
|
151
|
-
options.provider_ignores_state = original_provider_ignores_state
|
|
152
|
-
end
|
|
153
|
-
else
|
|
154
|
-
raise NoAuthorizationCodeError, 'must pass either a `code` (via URL or by an `fbsr_XXX` signed request cookie)'
|
|
155
|
-
end
|
|
156
|
-
end
|
|
157
|
-
|
|
158
|
-
def prune!(hash)
|
|
159
|
-
hash.delete_if do |_, value|
|
|
160
|
-
prune!(value) if value.is_a?(Hash)
|
|
161
|
-
value.nil? || (value.respond_to?(:empty?) && value.empty?)
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
|
|
165
|
-
def parse_signed_request(value)
|
|
166
|
-
signature, encoded_payload = value.split('.')
|
|
167
|
-
return if signature.nil?
|
|
168
|
-
|
|
169
|
-
decoded_hex_signature = base64_decode_url(signature)
|
|
170
|
-
decoded_payload = MultiJson.decode(base64_decode_url(encoded_payload))
|
|
171
|
-
|
|
172
|
-
unless decoded_payload['algorithm'] == 'HMAC-SHA256'
|
|
173
|
-
raise UnknownSignatureAlgorithmError, "unknown algorithm: #{decoded_payload['algorithm']}"
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
if valid_signature?(client.secret, decoded_hex_signature, encoded_payload)
|
|
177
|
-
decoded_payload
|
|
178
|
-
end
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
def valid_signature?(secret, signature, payload, algorithm = OpenSSL::Digest::SHA256.new)
|
|
182
|
-
OpenSSL::HMAC.digest(algorithm, secret, payload) == signature
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
def base64_decode_url(value)
|
|
186
|
-
value += '=' * (4 - value.size.modulo(4))
|
|
187
|
-
Base64.decode64(value.tr('-_', '+/'))
|
|
188
|
-
end
|
|
189
|
-
|
|
190
|
-
def image_url(uid, options)
|
|
191
|
-
uri_class = options[:secure_image_url] ? URI::HTTPS : URI::HTTP
|
|
192
|
-
url = uri_class.build({:host => 'auth.cibplus.com', :path => "/#{uid}/picture"})
|
|
193
|
-
|
|
194
|
-
query = if options[:image_size].is_a?(String)
|
|
195
|
-
{ :type => options[:image_size] }
|
|
196
|
-
elsif options[:image_size].is_a?(Hash)
|
|
197
|
-
options[:image_size]
|
|
198
|
-
end
|
|
199
|
-
url.query = Rack::Utils.build_query(query) if query
|
|
200
|
-
|
|
201
|
-
url.to_s
|
|
202
|
-
end
|
|
203
|
-
|
|
204
|
-
def appsecret_proof
|
|
205
|
-
@appsecret_proof ||= OpenSSL::HMAC.hexdigest(OpenSSL::Digest::SHA256.new, client.secret, access_token.token)
|
|
206
|
-
end
|
|
207
|
-
end
|
|
208
|
-
end
|
|
209
|
-
end
|