omniauth-auth0 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/{LICENSE.md → LICENSE} +0 -0
- data/README.md +23 -1
- data/examples/ruby-on-rails-webapp/.gitignore +17 -0
- data/examples/ruby-on-rails-webapp/Gemfile +48 -0
- data/examples/ruby-on-rails-webapp/README.md +20 -0
- data/examples/ruby-on-rails-webapp/README.rdoc +28 -0
- data/examples/ruby-on-rails-webapp/Rakefile +6 -0
- data/examples/ruby-on-rails-webapp/app/assets/images/.keep +0 -0
- data/examples/ruby-on-rails-webapp/app/assets/javascripts/application.js +13 -0
- data/examples/ruby-on-rails-webapp/app/assets/javascripts/home.js.erb +10 -0
- data/examples/ruby-on-rails-webapp/app/assets/stylesheets/application.css +114 -0
- data/examples/ruby-on-rails-webapp/app/controllers/application_controller.rb +5 -0
- data/examples/ruby-on-rails-webapp/app/controllers/auth0_controller.rb +14 -0
- data/examples/ruby-on-rails-webapp/app/controllers/concerns/.keep +0 -0
- data/examples/ruby-on-rails-webapp/app/controllers/dashboard_controller.rb +5 -0
- data/examples/ruby-on-rails-webapp/app/controllers/home_controller.rb +5 -0
- data/examples/ruby-on-rails-webapp/app/controllers/secured_controller.rb +13 -0
- data/examples/ruby-on-rails-webapp/app/helpers/application_helper.rb +2 -0
- data/examples/ruby-on-rails-webapp/app/helpers/callback_helper.rb +2 -0
- data/examples/ruby-on-rails-webapp/app/helpers/dashboard_helper.rb +2 -0
- data/examples/ruby-on-rails-webapp/app/helpers/home_helper.rb +2 -0
- data/examples/ruby-on-rails-webapp/app/mailers/.keep +0 -0
- data/examples/ruby-on-rails-webapp/app/models/.keep +0 -0
- data/examples/ruby-on-rails-webapp/app/models/concerns/.keep +0 -0
- data/examples/ruby-on-rails-webapp/app/views/auth0/failure.html.erb +4 -0
- data/examples/ruby-on-rails-webapp/app/views/dashboard/show.html.erb +12 -0
- data/examples/ruby-on-rails-webapp/app/views/home/show.html.erb +17 -0
- data/examples/ruby-on-rails-webapp/app/views/layouts/application.html.erb +21 -0
- data/examples/ruby-on-rails-webapp/bin/bundle +3 -0
- data/examples/ruby-on-rails-webapp/bin/rails +4 -0
- data/examples/ruby-on-rails-webapp/bin/rake +4 -0
- data/examples/ruby-on-rails-webapp/bin/spring +18 -0
- data/examples/ruby-on-rails-webapp/config.ru +4 -0
- data/examples/ruby-on-rails-webapp/config/application.rb +32 -0
- data/examples/ruby-on-rails-webapp/config/boot.rb +4 -0
- data/examples/ruby-on-rails-webapp/config/database.yml +20 -0
- data/examples/ruby-on-rails-webapp/config/environment.rb +5 -0
- data/examples/ruby-on-rails-webapp/config/environments/development.rb +39 -0
- data/examples/ruby-on-rails-webapp/config/environments/production.rb +85 -0
- data/examples/ruby-on-rails-webapp/config/environments/test.rb +39 -0
- data/examples/ruby-on-rails-webapp/config/initializers/01_dotenv.rb +4 -0
- data/examples/ruby-on-rails-webapp/config/initializers/auth0.rb +9 -0
- data/examples/ruby-on-rails-webapp/config/initializers/backtrace_silencers.rb +7 -0
- data/examples/ruby-on-rails-webapp/config/initializers/cookies_serializer.rb +3 -0
- data/examples/ruby-on-rails-webapp/config/initializers/filter_parameter_logging.rb +4 -0
- data/examples/ruby-on-rails-webapp/config/initializers/inflections.rb +16 -0
- data/examples/ruby-on-rails-webapp/config/initializers/mime_types.rb +4 -0
- data/examples/ruby-on-rails-webapp/config/initializers/session_store.rb +3 -0
- data/examples/ruby-on-rails-webapp/config/initializers/wrap_parameters.rb +14 -0
- data/examples/ruby-on-rails-webapp/config/locales/en.yml +23 -0
- data/examples/ruby-on-rails-webapp/config/routes.rb +66 -0
- data/examples/ruby-on-rails-webapp/config/secrets.yml +35 -0
- data/examples/ruby-on-rails-webapp/db/seeds.rb +7 -0
- data/examples/ruby-on-rails-webapp/lib/assets/.keep +0 -0
- data/examples/ruby-on-rails-webapp/lib/tasks/.keep +0 -0
- data/examples/ruby-on-rails-webapp/log/.keep +0 -0
- data/examples/ruby-on-rails-webapp/public/404.html +67 -0
- data/examples/ruby-on-rails-webapp/public/422.html +67 -0
- data/examples/ruby-on-rails-webapp/public/500.html +66 -0
- data/examples/ruby-on-rails-webapp/public/favicon.ico +0 -0
- data/examples/ruby-on-rails-webapp/public/robots.txt +5 -0
- data/examples/ruby-on-rails-webapp/test/controllers/.keep +0 -0
- data/examples/ruby-on-rails-webapp/test/controllers/callback_controller_test.rb +14 -0
- data/examples/ruby-on-rails-webapp/test/controllers/dashboard_controller_test.rb +9 -0
- data/examples/ruby-on-rails-webapp/test/controllers/home_controller_test.rb +9 -0
- data/examples/ruby-on-rails-webapp/test/fixtures/.keep +0 -0
- data/examples/ruby-on-rails-webapp/test/helpers/.keep +0 -0
- data/examples/ruby-on-rails-webapp/test/helpers/callback_helper_test.rb +4 -0
- data/examples/ruby-on-rails-webapp/test/helpers/dashboard_helper_test.rb +4 -0
- data/examples/ruby-on-rails-webapp/test/helpers/home_helper_test.rb +4 -0
- data/examples/ruby-on-rails-webapp/test/integration/.keep +0 -0
- data/examples/ruby-on-rails-webapp/test/mailers/.keep +0 -0
- data/examples/ruby-on-rails-webapp/test/models/.keep +0 -0
- data/examples/ruby-on-rails-webapp/test/test_helper.rb +13 -0
- data/examples/ruby-on-rails-webapp/vendor/assets/javascripts/.keep +0 -0
- data/examples/ruby-on-rails-webapp/vendor/assets/stylesheets/.keep +0 -0
- data/lib/omniauth-auth0.rb +1 -1
- data/lib/omniauth-auth0/version.rb +3 -0
- data/lib/omniauth/strategies/auth0.rb +9 -2
- data/omniauth-auth0.gemspec +3 -2
- data/spec/omniauth/strategies/auth0_spec.rb +45 -34
- metadata +116 -28
- data/lib/auth0/version.rb +0 -3
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
|
2
|
+
|
|
3
|
+
# Your secret key is used for verifying the integrity of signed cookies.
|
|
4
|
+
# If you change this key, all old signed cookies will become invalid!
|
|
5
|
+
|
|
6
|
+
# Make sure the secret is at least 30 characters and all random,
|
|
7
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
|
8
|
+
# You can use `rake secret` to generate a secure secret key.
|
|
9
|
+
|
|
10
|
+
# Make sure the secrets in this file are kept private
|
|
11
|
+
# if you're sharing your code publicly.
|
|
12
|
+
|
|
13
|
+
development:
|
|
14
|
+
secret_key_base: 44943afd8bfa7c8f48302d23a56af7a44766e516fc9b2585e9b198fb55e628e1a11ff2b876f193068f23dac95031e2d36fce28341f429076fcc322df68a4c572
|
|
15
|
+
auth0_client_id: <%= ENV["AUTH0_CLIENT_ID"] %>
|
|
16
|
+
auth0_client_secret: <%= ENV["AUTH0_CLIENT_SECRET"] %>
|
|
17
|
+
auth0_domain: <%= ENV["AUTH0_DOMAIN"] %>
|
|
18
|
+
auth0_callback_url: <%= ENV["AUTH0_CALLBACK_URL"] %>
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
test:
|
|
22
|
+
secret_key_base: 730ab4e74b6278ea9ecf8da4975ce7959836fc082b4974eb3cb65e0026be59b6502082b23fcecea9c611b5e5059632f876cdc7d5b31b3e80fc7c7b76c70e85b3
|
|
23
|
+
auth0_client_id: <%= ENV["AUTH0_CLIENT_ID"] %>
|
|
24
|
+
auth0_client_secret: <%= ENV["AUTH0_CLIENT_SECRET"] %>
|
|
25
|
+
auth0_domain: <%= ENV["AUTH0_DOMAIN"] %>
|
|
26
|
+
auth0_callback_url: <%= ENV["AUTH0_CALLBACK_URL"] %>
|
|
27
|
+
|
|
28
|
+
# Do not keep production secrets in the repository,
|
|
29
|
+
# instead read values from the environment.
|
|
30
|
+
production:
|
|
31
|
+
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
|
32
|
+
auth0_client_id: <%= ENV["AUTH0_CLIENT_ID"] %>
|
|
33
|
+
auth0_client_secret: <%= ENV["AUTH0_CLIENT_SECRET"] %>
|
|
34
|
+
auth0_domain: <%= ENV["AUTH0_DOMAIN"] %>
|
|
35
|
+
auth0_callback_url: <%= ENV["AUTH0_CALLBACK_URL"] %>
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# This file should contain all the record creation needed to seed the database with its default values.
|
|
2
|
+
# The data can then be loaded with the rake db:seed (or created alongside the db with db:setup).
|
|
3
|
+
#
|
|
4
|
+
# Examples:
|
|
5
|
+
#
|
|
6
|
+
# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }])
|
|
7
|
+
# Mayor.create(name: 'Emanuel', city: cities.first)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The page you were looking for doesn't exist (404)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/404.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The page you were looking for doesn't exist.</h1>
|
|
62
|
+
<p>You may have mistyped the address or the page may have moved.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>The change you wanted was rejected (422)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/422.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>The change you wanted was rejected.</h1>
|
|
62
|
+
<p>Maybe you tried to change something you didn't have access to.</p>
|
|
63
|
+
</div>
|
|
64
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
65
|
+
</div>
|
|
66
|
+
</body>
|
|
67
|
+
</html>
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>We're sorry, but something went wrong (500)</title>
|
|
5
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
6
|
+
<style>
|
|
7
|
+
body {
|
|
8
|
+
background-color: #EFEFEF;
|
|
9
|
+
color: #2E2F30;
|
|
10
|
+
text-align: center;
|
|
11
|
+
font-family: arial, sans-serif;
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
div.dialog {
|
|
16
|
+
width: 95%;
|
|
17
|
+
max-width: 33em;
|
|
18
|
+
margin: 4em auto 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
div.dialog > div {
|
|
22
|
+
border: 1px solid #CCC;
|
|
23
|
+
border-right-color: #999;
|
|
24
|
+
border-left-color: #999;
|
|
25
|
+
border-bottom-color: #BBB;
|
|
26
|
+
border-top: #B00100 solid 4px;
|
|
27
|
+
border-top-left-radius: 9px;
|
|
28
|
+
border-top-right-radius: 9px;
|
|
29
|
+
background-color: white;
|
|
30
|
+
padding: 7px 12% 0;
|
|
31
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
h1 {
|
|
35
|
+
font-size: 100%;
|
|
36
|
+
color: #730E15;
|
|
37
|
+
line-height: 1.5em;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
div.dialog > p {
|
|
41
|
+
margin: 0 0 1em;
|
|
42
|
+
padding: 1em;
|
|
43
|
+
background-color: #F7F7F7;
|
|
44
|
+
border: 1px solid #CCC;
|
|
45
|
+
border-right-color: #999;
|
|
46
|
+
border-left-color: #999;
|
|
47
|
+
border-bottom-color: #999;
|
|
48
|
+
border-bottom-left-radius: 4px;
|
|
49
|
+
border-bottom-right-radius: 4px;
|
|
50
|
+
border-top-color: #DADADA;
|
|
51
|
+
color: #666;
|
|
52
|
+
box-shadow: 0 3px 8px rgba(50, 50, 50, 0.17);
|
|
53
|
+
}
|
|
54
|
+
</style>
|
|
55
|
+
</head>
|
|
56
|
+
|
|
57
|
+
<body>
|
|
58
|
+
<!-- This file lives in public/500.html -->
|
|
59
|
+
<div class="dialog">
|
|
60
|
+
<div>
|
|
61
|
+
<h1>We're sorry, but something went wrong.</h1>
|
|
62
|
+
</div>
|
|
63
|
+
<p>If you are the application owner check the logs for more information.</p>
|
|
64
|
+
</div>
|
|
65
|
+
</body>
|
|
66
|
+
</html>
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
2
|
+
require File.expand_path('../../config/environment', __FILE__)
|
|
3
|
+
require 'rails/test_help'
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
|
7
|
+
#
|
|
8
|
+
# Note: You'll currently still have to declare fixtures explicitly in integration tests
|
|
9
|
+
# -- they do not yet inherit this setting
|
|
10
|
+
fixtures :all
|
|
11
|
+
|
|
12
|
+
# Add more helper methods to be used by all tests here...
|
|
13
|
+
end
|
|
File without changes
|
|
File without changes
|
data/lib/omniauth-auth0.rb
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
require "auth0/version"
|
|
1
|
+
require "omniauth-auth0/version"
|
|
2
2
|
require "omniauth/strategies/auth0"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
require "base64"
|
|
1
2
|
require "omniauth-oauth2"
|
|
2
3
|
|
|
3
4
|
module OmniAuth
|
|
@@ -23,8 +24,8 @@ module OmniAuth
|
|
|
23
24
|
@options.connection = args[4] unless args[4].nil?
|
|
24
25
|
|
|
25
26
|
@options.client_options.site = "https://#{options[:namespace]}"
|
|
26
|
-
@options.client_options.authorize_url = "https://#{options[:namespace]}/authorize"
|
|
27
|
-
@options.client_options.token_url = "https://#{options[:namespace]}/oauth/token"
|
|
27
|
+
@options.client_options.authorize_url = "https://#{options[:namespace]}/authorize?#{client_info_querystring}"
|
|
28
|
+
@options.client_options.token_url = "https://#{options[:namespace]}/oauth/token?#{client_info_querystring}"
|
|
28
29
|
@options.client_options.userinfo_url = "https://#{options[:namespace]}/userinfo"
|
|
29
30
|
end
|
|
30
31
|
|
|
@@ -70,6 +71,12 @@ module OmniAuth
|
|
|
70
71
|
def raw_info
|
|
71
72
|
@raw_info ||= access_token.get(options.client_options.userinfo_url).parsed
|
|
72
73
|
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
def client_info_querystring
|
|
77
|
+
client_info = JSON.dump({name: 'omniauth-auth0', version: ::Auth0::VERSION})
|
|
78
|
+
"auth0Client=" + Base64.urlsafe_encode64(client_info)
|
|
79
|
+
end
|
|
73
80
|
end
|
|
74
81
|
end
|
|
75
82
|
end
|
data/omniauth-auth0.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
|
2
2
|
$:.push File.expand_path("../lib", __FILE__)
|
|
3
|
-
require "auth0/version"
|
|
3
|
+
require "omniauth-auth0/version"
|
|
4
4
|
|
|
5
5
|
Gem::Specification.new do |s|
|
|
6
6
|
s.name = "omniauth-auth0"
|
|
@@ -30,6 +30,7 @@ omniauth-auth0 is the omniauth strategy for Auth0.
|
|
|
30
30
|
s.add_development_dependency 'simplecov', '~> 0.9', '>= 0.9.1'
|
|
31
31
|
s.add_development_dependency 'webmock', '~> 1.20', '>= 1.20.4'
|
|
32
32
|
s.add_development_dependency 'rake', '~> 10.3', '>= 10.3.2'
|
|
33
|
-
|
|
33
|
+
s.add_development_dependency 'gem-release', '~> 0.7'
|
|
34
|
+
|
|
34
35
|
s.license = 'MIT'
|
|
35
36
|
end
|
|
@@ -9,12 +9,12 @@ describe OmniAuth::Strategies::Auth0 do
|
|
|
9
9
|
before :each do
|
|
10
10
|
OmniAuth.config.test_mode = true
|
|
11
11
|
@request = double('Request')
|
|
12
|
-
@request.
|
|
13
|
-
@request.
|
|
14
|
-
@request.
|
|
12
|
+
allow(@request).to receive(:params)
|
|
13
|
+
allow(@request).to receive(:cookies)
|
|
14
|
+
allow(@request).to receive(:env)
|
|
15
15
|
|
|
16
16
|
@session = double('Session')
|
|
17
|
-
@session.
|
|
17
|
+
allow(@session).to receive(:delete).with('omniauth.state').and_return('state')
|
|
18
18
|
end
|
|
19
19
|
|
|
20
20
|
after do
|
|
@@ -24,24 +24,33 @@ describe OmniAuth::Strategies::Auth0 do
|
|
|
24
24
|
subject do
|
|
25
25
|
OmniAuth::Strategies::Auth0.new(app,
|
|
26
26
|
"client_id", "client_secret", "tenny.auth0.com:3000").tap do |strategy|
|
|
27
|
-
strategy.
|
|
27
|
+
allow(strategy).to receive(:request) { @request }
|
|
28
28
|
end
|
|
29
29
|
end
|
|
30
30
|
|
|
31
31
|
context "initiation" do
|
|
32
|
+
let(:base64_token) {
|
|
33
|
+
Base64.urlsafe_encode64('{"name":"omniauth-auth0","version":"'+Auth0::VERSION+'"}')
|
|
34
|
+
}
|
|
35
|
+
|
|
32
36
|
it "uses the correct site" do
|
|
33
|
-
subject.options.client_options.site.
|
|
34
|
-
should == "https://tenny.auth0.com:3000"
|
|
37
|
+
expect(subject.options.client_options.site).to eql "https://tenny.auth0.com:3000"
|
|
35
38
|
end
|
|
36
39
|
|
|
37
40
|
it "uses the correct authorize_url" do
|
|
38
|
-
subject.options.client_options.authorize_url.
|
|
39
|
-
|
|
41
|
+
expect(subject.options.client_options.authorize_url).
|
|
42
|
+
to eql "https://tenny.auth0.com:3000/authorize?auth0Client=#{base64_token}"
|
|
43
|
+
|
|
40
44
|
end
|
|
41
45
|
|
|
42
46
|
it "uses the correct token_url" do
|
|
43
|
-
subject.options.client_options.token_url.
|
|
44
|
-
|
|
47
|
+
expect(subject.options.client_options.token_url).
|
|
48
|
+
to eql "https://tenny.auth0.com:3000/oauth/token?auth0Client=#{base64_token}"
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "uses the correct userinfo url" do
|
|
52
|
+
expect(subject.options.client_options.userinfo_url).
|
|
53
|
+
to eql "https://tenny.auth0.com:3000/userinfo"
|
|
45
54
|
end
|
|
46
55
|
|
|
47
56
|
it "should raise an ArgumentError error if no namespace passed" do
|
|
@@ -59,11 +68,11 @@ describe OmniAuth::Strategies::Auth0 do
|
|
|
59
68
|
end
|
|
60
69
|
|
|
61
70
|
it "authorize params" do
|
|
62
|
-
subject.
|
|
71
|
+
allow(subject).to receive(:request) { double('Request', {:params => {
|
|
63
72
|
"connection" => "google-oauth2", "redirect_uri" => "redirect_uri" }, :env => {}}) }
|
|
64
|
-
subject.authorize_params.include
|
|
65
|
-
subject.authorize_params.include
|
|
66
|
-
subject.authorize_params.include
|
|
73
|
+
expect(subject.authorize_params).to include("connection")
|
|
74
|
+
expect(subject.authorize_params).to include("state")
|
|
75
|
+
expect(subject.authorize_params).to include("redirect_uri")
|
|
67
76
|
end
|
|
68
77
|
end
|
|
69
78
|
|
|
@@ -90,66 +99,68 @@ describe OmniAuth::Strategies::Auth0 do
|
|
|
90
99
|
"picture" => "pic",
|
|
91
100
|
"user_id" => "google-oauth2|102835921788417079450"
|
|
92
101
|
}
|
|
93
|
-
subject.
|
|
102
|
+
allow(subject).to receive(:raw_info) { @raw_info }
|
|
94
103
|
end
|
|
95
104
|
|
|
96
105
|
context "info" do
|
|
97
106
|
it 'returns the uid (required)' do
|
|
98
|
-
subject.uid.
|
|
107
|
+
expect(subject.uid).to eq('google-oauth2|102835921788417079450')
|
|
99
108
|
end
|
|
100
109
|
|
|
101
110
|
it 'returns the name (required)' do
|
|
102
|
-
subject.info[:name].
|
|
111
|
+
expect(subject.info[:name]).to eq('FirstName LastName')
|
|
103
112
|
end
|
|
104
113
|
|
|
105
114
|
it 'returns the email' do
|
|
106
|
-
subject.info[:email].
|
|
115
|
+
expect(subject.info[:email]).to eq('user@mail.com')
|
|
107
116
|
end
|
|
108
117
|
|
|
109
118
|
it 'returns the nickname' do
|
|
110
|
-
subject.info[:nickname].
|
|
119
|
+
expect(subject.info[:nickname]).to eq('nick')
|
|
111
120
|
end
|
|
112
121
|
|
|
113
122
|
it 'returns the last name' do
|
|
114
|
-
subject.info[:last_name].
|
|
123
|
+
expect(subject.info[:last_name]).to eq('LastName')
|
|
115
124
|
end
|
|
116
125
|
|
|
117
126
|
it 'returns the first name' do
|
|
118
|
-
subject.info[:first_name].
|
|
127
|
+
expect(subject.info[:first_name]).to eq('FirstName')
|
|
119
128
|
end
|
|
120
129
|
|
|
121
130
|
it 'returns the location' do
|
|
122
|
-
subject.info[:location].
|
|
131
|
+
expect(subject.info[:location]).to eq('en')
|
|
123
132
|
end
|
|
124
133
|
|
|
125
134
|
it 'returns the image' do
|
|
126
|
-
subject.info[:image].
|
|
135
|
+
expect(subject.info[:image]).to eq('pic')
|
|
127
136
|
end
|
|
128
137
|
end
|
|
129
138
|
|
|
130
139
|
context "get token" do
|
|
131
140
|
before :each do
|
|
132
141
|
@access_token = double('OAuth2::AccessToken')
|
|
133
|
-
|
|
134
|
-
@access_token.
|
|
135
|
-
@access_token.
|
|
136
|
-
@access_token.
|
|
137
|
-
@access_token.
|
|
138
|
-
|
|
142
|
+
|
|
143
|
+
allow(@access_token).to receive(:token)
|
|
144
|
+
allow(@access_token).to receive(:expires?)
|
|
145
|
+
allow(@access_token).to receive(:expires_at)
|
|
146
|
+
allow(@access_token).to receive(:refresh_token)
|
|
147
|
+
allow(@access_token).to receive(:params)
|
|
148
|
+
|
|
149
|
+
allow(subject).to receive(:access_token) { @access_token }
|
|
139
150
|
end
|
|
140
151
|
|
|
141
152
|
it 'returns a Hash' do
|
|
142
|
-
subject.credentials.
|
|
153
|
+
expect(subject.credentials).to be_a(Hash)
|
|
143
154
|
end
|
|
144
155
|
|
|
145
156
|
it 'returns the token' do
|
|
146
|
-
@access_token.
|
|
157
|
+
allow(@access_token).to receive(:token) {
|
|
147
158
|
{
|
|
148
159
|
:access_token => "OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI",
|
|
149
160
|
:token_type => "bearer"
|
|
150
161
|
} }
|
|
151
|
-
subject.credentials['token'][:access_token].
|
|
152
|
-
subject.credentials['token'][:token_type].
|
|
162
|
+
expect(subject.credentials['token'][:access_token]).to eq('OTqSFa9zrh0VRGAZHH4QPJISCoynRwSy9FocUazuaU950EVcISsJo3pST11iTCiI')
|
|
163
|
+
expect(subject.credentials['token'][:token_type]).to eq('bearer')
|
|
153
164
|
end
|
|
154
165
|
end
|
|
155
166
|
end
|