omniauth-auth0 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -0
  3. data/{LICENSE.md → LICENSE} +0 -0
  4. data/README.md +23 -1
  5. data/examples/ruby-on-rails-webapp/.gitignore +17 -0
  6. data/examples/ruby-on-rails-webapp/Gemfile +48 -0
  7. data/examples/ruby-on-rails-webapp/README.md +20 -0
  8. data/examples/ruby-on-rails-webapp/README.rdoc +28 -0
  9. data/examples/ruby-on-rails-webapp/Rakefile +6 -0
  10. data/examples/ruby-on-rails-webapp/app/assets/images/.keep +0 -0
  11. data/examples/ruby-on-rails-webapp/app/assets/javascripts/application.js +13 -0
  12. data/examples/ruby-on-rails-webapp/app/assets/javascripts/home.js.erb +10 -0
  13. data/examples/ruby-on-rails-webapp/app/assets/stylesheets/application.css +114 -0
  14. data/examples/ruby-on-rails-webapp/app/controllers/application_controller.rb +5 -0
  15. data/examples/ruby-on-rails-webapp/app/controllers/auth0_controller.rb +14 -0
  16. data/examples/ruby-on-rails-webapp/app/controllers/concerns/.keep +0 -0
  17. data/examples/ruby-on-rails-webapp/app/controllers/dashboard_controller.rb +5 -0
  18. data/examples/ruby-on-rails-webapp/app/controllers/home_controller.rb +5 -0
  19. data/examples/ruby-on-rails-webapp/app/controllers/secured_controller.rb +13 -0
  20. data/examples/ruby-on-rails-webapp/app/helpers/application_helper.rb +2 -0
  21. data/examples/ruby-on-rails-webapp/app/helpers/callback_helper.rb +2 -0
  22. data/examples/ruby-on-rails-webapp/app/helpers/dashboard_helper.rb +2 -0
  23. data/examples/ruby-on-rails-webapp/app/helpers/home_helper.rb +2 -0
  24. data/examples/ruby-on-rails-webapp/app/mailers/.keep +0 -0
  25. data/examples/ruby-on-rails-webapp/app/models/.keep +0 -0
  26. data/examples/ruby-on-rails-webapp/app/models/concerns/.keep +0 -0
  27. data/examples/ruby-on-rails-webapp/app/views/auth0/failure.html.erb +4 -0
  28. data/examples/ruby-on-rails-webapp/app/views/dashboard/show.html.erb +12 -0
  29. data/examples/ruby-on-rails-webapp/app/views/home/show.html.erb +17 -0
  30. data/examples/ruby-on-rails-webapp/app/views/layouts/application.html.erb +21 -0
  31. data/examples/ruby-on-rails-webapp/bin/bundle +3 -0
  32. data/examples/ruby-on-rails-webapp/bin/rails +4 -0
  33. data/examples/ruby-on-rails-webapp/bin/rake +4 -0
  34. data/examples/ruby-on-rails-webapp/bin/spring +18 -0
  35. data/examples/ruby-on-rails-webapp/config.ru +4 -0
  36. data/examples/ruby-on-rails-webapp/config/application.rb +32 -0
  37. data/examples/ruby-on-rails-webapp/config/boot.rb +4 -0
  38. data/examples/ruby-on-rails-webapp/config/database.yml +20 -0
  39. data/examples/ruby-on-rails-webapp/config/environment.rb +5 -0
  40. data/examples/ruby-on-rails-webapp/config/environments/development.rb +39 -0
  41. data/examples/ruby-on-rails-webapp/config/environments/production.rb +85 -0
  42. data/examples/ruby-on-rails-webapp/config/environments/test.rb +39 -0
  43. data/examples/ruby-on-rails-webapp/config/initializers/01_dotenv.rb +4 -0
  44. data/examples/ruby-on-rails-webapp/config/initializers/auth0.rb +9 -0
  45. data/examples/ruby-on-rails-webapp/config/initializers/backtrace_silencers.rb +7 -0
  46. data/examples/ruby-on-rails-webapp/config/initializers/cookies_serializer.rb +3 -0
  47. data/examples/ruby-on-rails-webapp/config/initializers/filter_parameter_logging.rb +4 -0
  48. data/examples/ruby-on-rails-webapp/config/initializers/inflections.rb +16 -0
  49. data/examples/ruby-on-rails-webapp/config/initializers/mime_types.rb +4 -0
  50. data/examples/ruby-on-rails-webapp/config/initializers/session_store.rb +3 -0
  51. data/examples/ruby-on-rails-webapp/config/initializers/wrap_parameters.rb +14 -0
  52. data/examples/ruby-on-rails-webapp/config/locales/en.yml +23 -0
  53. data/examples/ruby-on-rails-webapp/config/routes.rb +66 -0
  54. data/examples/ruby-on-rails-webapp/config/secrets.yml +35 -0
  55. data/examples/ruby-on-rails-webapp/db/seeds.rb +7 -0
  56. data/examples/ruby-on-rails-webapp/lib/assets/.keep +0 -0
  57. data/examples/ruby-on-rails-webapp/lib/tasks/.keep +0 -0
  58. data/examples/ruby-on-rails-webapp/log/.keep +0 -0
  59. data/examples/ruby-on-rails-webapp/public/404.html +67 -0
  60. data/examples/ruby-on-rails-webapp/public/422.html +67 -0
  61. data/examples/ruby-on-rails-webapp/public/500.html +66 -0
  62. data/examples/ruby-on-rails-webapp/public/favicon.ico +0 -0
  63. data/examples/ruby-on-rails-webapp/public/robots.txt +5 -0
  64. data/examples/ruby-on-rails-webapp/test/controllers/.keep +0 -0
  65. data/examples/ruby-on-rails-webapp/test/controllers/callback_controller_test.rb +14 -0
  66. data/examples/ruby-on-rails-webapp/test/controllers/dashboard_controller_test.rb +9 -0
  67. data/examples/ruby-on-rails-webapp/test/controllers/home_controller_test.rb +9 -0
  68. data/examples/ruby-on-rails-webapp/test/fixtures/.keep +0 -0
  69. data/examples/ruby-on-rails-webapp/test/helpers/.keep +0 -0
  70. data/examples/ruby-on-rails-webapp/test/helpers/callback_helper_test.rb +4 -0
  71. data/examples/ruby-on-rails-webapp/test/helpers/dashboard_helper_test.rb +4 -0
  72. data/examples/ruby-on-rails-webapp/test/helpers/home_helper_test.rb +4 -0
  73. data/examples/ruby-on-rails-webapp/test/integration/.keep +0 -0
  74. data/examples/ruby-on-rails-webapp/test/mailers/.keep +0 -0
  75. data/examples/ruby-on-rails-webapp/test/models/.keep +0 -0
  76. data/examples/ruby-on-rails-webapp/test/test_helper.rb +13 -0
  77. data/examples/ruby-on-rails-webapp/vendor/assets/javascripts/.keep +0 -0
  78. data/examples/ruby-on-rails-webapp/vendor/assets/stylesheets/.keep +0 -0
  79. data/lib/omniauth-auth0.rb +1 -1
  80. data/lib/omniauth-auth0/version.rb +3 -0
  81. data/lib/omniauth/strategies/auth0.rb +9 -2
  82. data/omniauth-auth0.gemspec +3 -2
  83. data/spec/omniauth/strategies/auth0_spec.rb +45 -34
  84. metadata +116 -28
  85. data/lib/auth0/version.rb +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 05c5b449f7be964fb837070c954f284e432fe2f3
4
- data.tar.gz: f6c37ee4ade8bc429c76f524924f5480c60f8556
3
+ metadata.gz: bd50cc68d4204cea39dfe9768136109b57134ea6
4
+ data.tar.gz: 173e0a227c26d92344b4efc4ad0e9488e661f00d
5
5
  SHA512:
6
- metadata.gz: 6b7803e4c457f940eb3d236a1b356564ab14093ed6dd3fe9bdeee3ac13c57395e8a1911909ee678aa3a19ff36c9dd85305eec5569875d06c03f9d2dbee8e8b3d
7
- data.tar.gz: 0daf87a9767431012304e795cdebd5c7358b4d14c469170db0ec11775dcc688edd2556df22e760e994af941da0c4fe7d80001710deba2c18067568f3660aa3dd
6
+ metadata.gz: 98af35c60a404d1bd132af797c1febfa0c5e652c20a34335495f448b230eabe013153699c80a51a9f9b51ce65fd559f7f925df78bb7b44dd0024504ca776ff47
7
+ data.tar.gz: 75972c6b9c26082ef8d1eab1fd3c111be6424b7a07c5a7fc6cfa8160353043b6e53ce4a89817d930f6c2f1459bd31c46707702522af86e90b6369612754ea83f
data/.travis.yml CHANGED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.1.0
File without changes
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ [![Build Status](https://travis-ci.org/auth0/omniauth-auth0.svg)](https://travis-ci.org/auth0/omniauth-auth0)
2
+
1
3
  # OmniAuth Auth0
2
4
 
3
5
  This is the official OmniAuth strategy for authenticating to [Auth0](https://auth0.com).
@@ -22,6 +24,12 @@ Rails.application.config.middleware.use OmniAuth::Builder do
22
24
  end
23
25
  ```
24
26
 
27
+ If you want to force an identity provider you can simply redirect to the Omniauth path like this:
28
+
29
+ ```ruby
30
+ redirect_to '/auth/auth0?connection=CONNECTION_NAME'
31
+ ```
32
+
25
33
  ### Sinatra
26
34
 
27
35
  ```ruby
@@ -32,9 +40,15 @@ end
32
40
 
33
41
  > Optional you can set the `:provider_ignores_state` passing a fourth parameter. By default it is true.
34
42
 
43
+ If you want to force to force an identity provider you can simply redirect to Omniauth path like this:
44
+
45
+ ```ruby
46
+ redirect to('/auth/auth0?connection=CONNECTION_NAME')
47
+ ```
48
+
35
49
  ### Login widget
36
50
 
37
- Integrate the widget in one of your pages as described [here](http://docs.auth0.com/widget) or use links as described in the same link.
51
+ Integrate the widget in one of your pages as described [here](http://auth0.com/docs/lock) or use links as described in the same link.
38
52
 
39
53
  ### Auth Hash
40
54
 
@@ -103,3 +117,11 @@ For more information about [auth0](http://auth0.com) contact our [documentation
103
117
  ## Issue Reporting
104
118
 
105
119
  If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The [Responsible Disclosure Program](https://auth0.com/whitehat) details the procedure for disclosing security issues.
120
+
121
+ ## Author
122
+
123
+ [Auth0](auth0.com)
124
+
125
+ ## License
126
+
127
+ This project is licensed under the MIT license. See the [LICENSE](LICENSE) file for more info.
@@ -0,0 +1,17 @@
1
+ # See https://help.github.com/articles/ignoring-files for more about ignoring files.
2
+ #
3
+ # If you find yourself ignoring temporary files generated by your text editor
4
+ # or operating system, you probably want to add a global ignore instead:
5
+ # git config --global core.excludesfile '~/.gitignore_global'
6
+
7
+ # Ignore bundler config.
8
+ /.bundle
9
+
10
+ # Ignore the default SQLite database.
11
+ /db/*.sqlite3
12
+ /db/*.sqlite3-journal
13
+
14
+ # Ignore all logfiles and tempfiles.
15
+ /log/*.log
16
+ /tmp
17
+ .env
@@ -0,0 +1,48 @@
1
+ source 'https://rubygems.org'
2
+
3
+
4
+ # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
5
+ gem 'rails', '4.1.1'
6
+ # Use sqlite3 as the database for Active Record
7
+ gem 'sqlite3', group: :development
8
+ gem 'pry', group: :development
9
+ gem 'pg'
10
+ # Use SCSS for stylesheets
11
+ gem 'sass-rails', '~> 4.0.3'
12
+ # Use Uglifier as compressor for JavaScript assets
13
+ gem 'uglifier', '>= 1.3.0'
14
+ # Use CoffeeScript for .js.coffee assets and views
15
+ gem 'coffee-rails', '~> 4.0.0'
16
+ # See https://github.com/sstephenson/execjs#readme for more supported runtimes
17
+ # gem 'therubyracer', platforms: :ruby
18
+
19
+ gem 'rails_12factor', group: :production
20
+
21
+ # Use jquery as the JavaScript library
22
+ gem 'jquery-rails'
23
+ # Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
24
+ gem 'turbolinks'
25
+ # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
26
+ gem 'jbuilder', '~> 2.0'
27
+ # bundle exec rake doc:rails generates the API under doc/api.
28
+ gem 'sdoc', '~> 0.4.0', group: :doc
29
+
30
+ # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
31
+ gem 'spring', group: :development
32
+
33
+ gem 'omniauth', '~> 1.2'
34
+ gem 'omniauth-auth0', '~> 1.1'
35
+
36
+ gem 'dotenv', '~> 0.11.1', group: :development
37
+
38
+ # Use ActiveModel has_secure_password
39
+ # gem 'bcrypt', '~> 3.1.7'
40
+
41
+ # Use unicorn as the app server
42
+ # gem 'unicorn'
43
+
44
+ # Use Capistrano for deployment
45
+ # gem 'capistrano-rails', group: :development
46
+
47
+ # Use debugger
48
+ # gem 'debugger', group: [:development, :test]
@@ -0,0 +1,20 @@
1
+ #Auth0 + Ruby on Rails WebApp Seed
2
+ This is the seed project you need to use if you're going to create a regular WebApp with Ruby on Rails. If you want to build a Ruby On Rails API that will be used with a SPA or a Mobile device, please check this [other seed project](https://github.com/auth0/ruby-auth0/tree/master/examples/ruby-on-rails-api)
3
+
4
+ This example is deployed at Heroku at http://auth0-ror-webapp-sample.herokuapp.com/
5
+
6
+ #Running the example
7
+ In order to run the example you need to have ruby installed.
8
+
9
+ You also need to set the ClientSecret, ClientId, Domain and CallbackURL for your Auth0 app as enviroment variables with the following names respectively: AUTH0_CLIENT_SECRET, AUTH0_CLIENT_ID, AUTH0_DOMAIN and AUTH0_CALLBACK_URL.
10
+
11
+ For that, if you just create a file named .env in the directory and set the values like the following, the app will just work:
12
+
13
+ ````bash
14
+ # .env file
15
+ AUTH0_CLIENT_SECRET=myCoolSecret
16
+ AUTH0_CLIENT_ID=myCoolClientId
17
+ AUTH0_DOMAIN=samples.auth0.com
18
+ AUTH0_CALLBACK_URL=http://localhost:3000/auth/auth0/callback
19
+ ````
20
+ Once you've set those 4 enviroment variables, just run `rails s` and try calling [http://localhost:3000/](http://localhost:3000/)
@@ -0,0 +1,28 @@
1
+ == README
2
+
3
+ This README would normally document whatever steps are necessary to get the
4
+ application up and running.
5
+
6
+ Things you may want to cover:
7
+
8
+ * Ruby version
9
+
10
+ * System dependencies
11
+
12
+ * Configuration
13
+
14
+ * Database creation
15
+
16
+ * Database initialization
17
+
18
+ * How to run the test suite
19
+
20
+ * Services (job queues, cache servers, search engines, etc.)
21
+
22
+ * Deployment instructions
23
+
24
+ * ...
25
+
26
+
27
+ Please feel free to use a different markup language if you do not plan to run
28
+ <tt>rake doc:app</tt>.
@@ -0,0 +1,6 @@
1
+ # Add your own tasks in files placed in lib/tasks ending in .rake,
2
+ # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
+
4
+ require File.expand_path('../config/application', __FILE__)
5
+
6
+ Rails.application.load_tasks
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // compiled file.
9
+ //
10
+ // Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
11
+ // about supported directives.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,10 @@
1
+ var lock = new Auth0Lock('<%= Rails.application.secrets.auth0_client_id %>', '<%= Rails.application.secrets.auth0_domain %>');
2
+ function signin() {
3
+ lock.show({
4
+ callbackURL: 'http://localhost:3000/auth/auth0/callback', // use this in production '<%= Rails.application.secrets.auth0_callback_url %>'
5
+ responseType: 'code',
6
+ authParams: {
7
+ scope: 'openid profile'
8
+ }
9
+ });
10
+ }
@@ -0,0 +1,114 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9
+ * compiled file so the styles you add here take precedence over styles defined in any styles
10
+ * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11
+ * file per style scope.
12
+ *
13
+ *= require_tree .
14
+ *= require_self
15
+ */
16
+
17
+ body {
18
+ font-family: "proxima-nova", sans-serif;
19
+ text-align: center;
20
+ font-size: 300%;
21
+ font-weight: 100;
22
+ }
23
+ input[type=checkbox],
24
+ input[type=radio] {
25
+ position: absolute;
26
+ opacity: 0;
27
+ }
28
+ input[type=checkbox] + label,
29
+ input[type=radio] + label {
30
+ display: inline-block;
31
+ }
32
+ input[type=checkbox] + label:before,
33
+ input[type=radio] + label:before {
34
+ content: "";
35
+ display: inline-block;
36
+ vertical-align: -0.2em;
37
+ width: 1em;
38
+ height: 1em;
39
+ border: 0.15em solid #0074d9;
40
+ border-radius: 0.2em;
41
+ margin-right: 0.3em;
42
+ background-color: white;
43
+ }
44
+ input[type=radio] + label:before {
45
+ border-radius: 50%;
46
+ }
47
+ input[type=radio]:checked + label:before,
48
+ input[type=checkbox]:checked + label:before {
49
+ background-color: #0074d9;
50
+ box-shadow: inset 0 0 0 0.15em white;
51
+ }
52
+ input[type=radio]:focus + label:before,
53
+ input[type=checkbox]:focus + label:before {
54
+ outline: 0;
55
+ }
56
+ .btn {
57
+ font-size: 140%;
58
+ text-transform: uppercase;
59
+ letter-spacing: 1px;
60
+ border: 0;
61
+ background-color: #16214D;
62
+ color: white;
63
+ }
64
+ .btn:hover {
65
+ background-color: #44C7F4;
66
+ }
67
+ .btn:focus {
68
+ outline: none !important;
69
+ }
70
+ .btn.btn-lg {
71
+ padding: 20px 30px;
72
+ }
73
+ .btn:disabled {
74
+ background-color: #333;
75
+ color: #666;
76
+ }
77
+ h1,
78
+ h2,
79
+ h3 {
80
+ font-weight: 100;
81
+ }
82
+ #logo img {
83
+ width: 300px;
84
+ margin-bottom: 60px;
85
+ }
86
+ .home-description {
87
+ font-weight: 100;
88
+ margin: 100px 0;
89
+ }
90
+ h2 {
91
+ margin-top: 30px;
92
+ margin-bottom: 40px;
93
+ font-size: 200%;
94
+ }
95
+ label {
96
+ font-size: 100%;
97
+ font-weight: 300;
98
+ }
99
+ .btn-next {
100
+ margin-top: 30px;
101
+ }
102
+ .answer {
103
+ width: 70%;
104
+ margin: auto;
105
+ text-align: left;
106
+ padding-left: 10%;
107
+ margin-bottom: 20px;
108
+ }
109
+ .login-page .login-box {
110
+ padding: 100px 0;
111
+ }
112
+ pre {
113
+ text-align: left;
114
+ }
@@ -0,0 +1,5 @@
1
+ class ApplicationController < ActionController::Base
2
+ # Prevent CSRF attacks by raising an exception.
3
+ # For APIs, you may want to use :null_session instead.
4
+ protect_from_forgery with: :exception
5
+ end
@@ -0,0 +1,14 @@
1
+ class Auth0Controller < ApplicationController
2
+ def callback
3
+ # example request.env['omniauth.auth'] in https://github.com/auth0/omniauth-auth0#auth-hash
4
+ # id_token = session[:userinfo]['credentials']['id_token']
5
+ # store the user profile in session and redirect to root
6
+ session[:userinfo] = request.env['omniauth.auth']
7
+
8
+ redirect_to '/dashboard'
9
+ end
10
+
11
+ def failure
12
+ @error_msg = request.params['message']
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ class DashboardController < SecuredController
2
+ def show
3
+ @user = session[:userinfo]
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class HomeController < ApplicationController
2
+ def show
3
+
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ class SecuredController < ApplicationController
2
+
3
+ before_action :logged_in_using_omniauth?
4
+
5
+ private
6
+
7
+ def logged_in_using_omniauth?
8
+ unless session[:userinfo].present?
9
+ redirect_to '/'
10
+ end
11
+ end
12
+
13
+ end
@@ -0,0 +1,2 @@
1
+ module ApplicationHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module CallbackHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module DashboardHelper
2
+ end
@@ -0,0 +1,2 @@
1
+ module HomeHelper
2
+ end
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ <div class="home">
2
+ <h2>Error <%= @error_msg %></h2>
3
+ <p><%= @omniauth_error %></p>
4
+ </div>
@@ -0,0 +1,12 @@
1
+ <div class="home">
2
+ <div class="container">
3
+ <div class="login-page clearfix">
4
+ <div class="logged-in-box auth0-box logged-in">
5
+ <h1 id="logo"><img src="//cdn.auth0.com/samples/auth0_logo_final_blue_RGB.png" /></h1>
6
+ <img class="avatar" src="<%= @user[:info][:image] %>"/>
7
+ <h2>Welcome <%= @user[:info][:name] %></h2>
8
+ <pre><%= JSON.pretty_generate(@user[:info]) %></pre>
9
+ </div>
10
+ </div>
11
+ </div>
12
+ </div>
@@ -0,0 +1,17 @@
1
+ <% content_for :cdn_code do %>
2
+ <%= javascript_include_tag '//cdn.auth0.com/js/lock-7.0.min.js' %>
3
+ <% end %>
4
+ <div class="home">
5
+ <div class="container">
6
+ <div class="login-page clearfix">
7
+ <div class="login-box auth0-box before">
8
+ <img src="https://i.cloudup.com/StzWWrY34s.png" />
9
+ <h3>Auth0 Example</h3>
10
+ <p>Zero friction identity infrastructure, built for developers</p>
11
+ <a class="btn btn-primary btn-lg btn-login btn-block" onclick="signin()">SignIn</a>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </div>
16
+
17
+