devise_openid_authenticatable 1.2.1 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +18 -9
  4. data/CHANGELOG.rdoc +5 -0
  5. data/Gemfile +6 -1
  6. data/Gemfile.devise13 +4 -4
  7. data/Gemfile.devise13.lock +148 -0
  8. data/Gemfile.devise14 +4 -4
  9. data/Gemfile.devise14.lock +150 -0
  10. data/Gemfile.devise15 +4 -4
  11. data/Gemfile.devise15.lock +161 -0
  12. data/Gemfile.devise21 +4 -4
  13. data/Gemfile.devise21.lock +160 -0
  14. data/Gemfile.devise30 +5 -4
  15. data/Gemfile.devise30.lock +151 -0
  16. data/Gemfile.devise33 +12 -0
  17. data/Gemfile.devise33.lock +150 -0
  18. data/Gemfile.devise35 +13 -0
  19. data/Gemfile.devise35.lock +153 -0
  20. data/Gemfile.devise42 +14 -0
  21. data/Gemfile.devise42.lock +189 -0
  22. data/devise_openid_authenticatable.gemspec +4 -1
  23. data/lib/devise_openid_authenticatable/controller.rb +4 -4
  24. data/lib/devise_openid_authenticatable/strategy.rb +20 -8
  25. data/lib/devise_openid_authenticatable/version.rb +1 -1
  26. data/rails/Rakefile +6 -0
  27. data/rails/app/active_record/admin.rb +6 -0
  28. data/rails/app/active_record/shim.rb +2 -0
  29. data/rails/app/active_record/user.rb +7 -0
  30. data/rails/app/active_record/user_on_engine.rb +7 -0
  31. data/rails/app/active_record/user_on_main_app.rb +7 -0
  32. data/rails/app/active_record/user_without_email.rb +8 -0
  33. data/rails/app/controllers/admins/sessions_controller.rb +6 -0
  34. data/rails/app/controllers/admins_controller.rb +6 -0
  35. data/rails/app/controllers/application_controller.rb +11 -0
  36. data/rails/app/controllers/application_with_fake_engine.rb +30 -0
  37. data/rails/app/controllers/custom/registrations_controller.rb +31 -0
  38. data/rails/app/controllers/home_controller.rb +29 -0
  39. data/rails/app/controllers/publisher/registrations_controller.rb +2 -0
  40. data/rails/app/controllers/publisher/sessions_controller.rb +2 -0
  41. data/rails/app/controllers/users/omniauth_callbacks_controller.rb +14 -0
  42. data/rails/app/controllers/users_controller.rb +31 -0
  43. data/rails/app/helpers/application_helper.rb +3 -0
  44. data/rails/app/mailers/users/from_proc_mailer.rb +3 -0
  45. data/rails/app/mailers/users/mailer.rb +3 -0
  46. data/rails/app/mailers/users/reply_to_mailer.rb +4 -0
  47. data/rails/app/mongoid/admin.rb +29 -0
  48. data/rails/app/mongoid/shim.rb +23 -0
  49. data/rails/app/mongoid/user.rb +39 -0
  50. data/rails/app/mongoid/user_on_engine.rb +39 -0
  51. data/rails/app/mongoid/user_on_main_app.rb +39 -0
  52. data/rails/app/mongoid/user_without_email.rb +33 -0
  53. data/rails/app/views/admins/index.html.erb +1 -0
  54. data/rails/app/views/admins/sessions/new.html.erb +2 -0
  55. data/rails/app/views/home/admin_dashboard.html.erb +1 -0
  56. data/rails/app/views/home/index.html.erb +1 -0
  57. data/rails/app/views/home/join.html.erb +1 -0
  58. data/rails/app/views/home/private.html.erb +1 -0
  59. data/rails/app/views/home/user_dashboard.html.erb +1 -0
  60. data/rails/app/views/layouts/application.html.erb +24 -0
  61. data/rails/app/views/users/edit_form.html.erb +1 -0
  62. data/rails/app/views/users/index.html.erb +1 -0
  63. data/rails/app/views/users/mailer/confirmation_instructions.erb +1 -0
  64. data/rails/app/views/users/sessions/new.html.erb +1 -0
  65. data/rails/bin/bundle +3 -0
  66. data/rails/bin/rails +4 -0
  67. data/rails/bin/rake +4 -0
  68. data/rails/config.ru +4 -0
  69. data/rails/config/application.rb +44 -0
  70. data/rails/config/boot.rb +14 -0
  71. data/rails/config/database.yml +18 -0
  72. data/rails/config/environment.rb +5 -0
  73. data/rails/config/environments/development.rb +30 -0
  74. data/rails/config/environments/production.rb +86 -0
  75. data/rails/config/environments/test.rb +45 -0
  76. data/rails/config/initializers/backtrace_silencers.rb +7 -0
  77. data/rails/config/initializers/devise.rb +180 -0
  78. data/rails/config/initializers/inflections.rb +2 -0
  79. data/rails/config/initializers/secret_token.rb +3 -0
  80. data/rails/config/initializers/session_store.rb +1 -0
  81. data/rails/config/routes.rb +126 -0
  82. data/rails/db/migrate/20100401102949_create_tables.rb +75 -0
  83. data/rails/db/schema.rb +55 -0
  84. data/rails/lib/shared_admin.rb +17 -0
  85. data/rails/lib/shared_user.rb +30 -0
  86. data/rails/lib/shared_user_without_email.rb +26 -0
  87. data/rails/lib/shared_user_without_omniauth.rb +13 -0
  88. data/rails/public/404.html +26 -0
  89. data/rails/public/422.html +26 -0
  90. data/rails/public/500.html +26 -0
  91. data/rails/public/favicon.ico +0 -0
  92. data/spec/scenario/config/environments/test.rb +3 -2
  93. data/spec/scenario/config/initializers/devise.rb +3 -0
  94. data/spec/scenario/config/initializers/secret_token.rb +4 -1
  95. data/spec/spec_helper.rb +10 -4
  96. data/spec/strategy_spec.rb +38 -25
  97. metadata +96 -4
  98. data/rails/init.rb +0 -1
@@ -0,0 +1,2 @@
1
+ ActiveSupport::Inflector.inflections do |inflect|
2
+ end
@@ -0,0 +1,3 @@
1
+ config = Rails.application.config
2
+
3
+ config.secret_key_base = 'd588e99efff13a86461fd6ab82327823ad2f8feb5dc217ce652cdd9f0dfc5eb4b5a62a92d24d2574d7d51dfb1ea8dd453ea54e00cf672159a13104a135422a10'
@@ -0,0 +1 @@
1
+ RailsApp::Application.config.session_store :cookie_store, key: '_rails_app_session'
@@ -0,0 +1,126 @@
1
+ Rails.application.routes.draw do
2
+ # Resources for testing
3
+ resources :users, only: [:index] do
4
+ member do
5
+ get :expire
6
+ get :accept
7
+ get :edit_form
8
+ put :update_form
9
+ end
10
+
11
+ authenticate do
12
+ post :exhibit, on: :member
13
+ end
14
+ end
15
+
16
+ resources :admins, only: [:index]
17
+
18
+ # Users scope
19
+ devise_for :users, controllers: { omniauth_callbacks: "users/omniauth_callbacks" }
20
+
21
+ devise_for :user_on_main_apps,
22
+ class_name: 'UserOnMainApp',
23
+ router_name: :main_app,
24
+ module: :devise
25
+
26
+ devise_for :user_on_engines,
27
+ class_name: 'UserOnEngine',
28
+ router_name: :fake_engine,
29
+ module: :devise
30
+
31
+ devise_for :user_without_email,
32
+ class_name: 'UserWithoutEmail',
33
+ router_name: :main_app,
34
+ module: :devise
35
+
36
+ as :user do
37
+ get "/as/sign_in", to: "devise/sessions#new"
38
+ end
39
+
40
+ get "/sign_in", to: "devise/sessions#new"
41
+
42
+ # Routes for custom controller testing
43
+ devise_for :user, only: [:registrations], controllers: { registrations: "custom/registrations" }, as: :custom, path: :custom
44
+
45
+ # Admin scope
46
+ devise_for :admin, path: "admin_area", controllers: { sessions: :"admins/sessions" }, skip: :passwords
47
+
48
+ get "/admin_area/home", to: "admins#index", as: :admin_root
49
+ get "/anywhere", to: "foo#bar", as: :new_admin_password
50
+
51
+ authenticate(:admin) do
52
+ get "/private", to: "home#private", as: :private
53
+ end
54
+
55
+ authenticate(:admin, lambda { |admin| admin.active? }) do
56
+ get "/private/active", to: "home#private", as: :private_active
57
+ end
58
+
59
+ authenticated :admin do
60
+ get "/dashboard", to: "home#admin_dashboard"
61
+ end
62
+
63
+ authenticated :admin, lambda { |admin| admin.active? } do
64
+ get "/dashboard/active", to: "home#admin_dashboard"
65
+ end
66
+
67
+ authenticated do
68
+ get "/dashboard", to: "home#user_dashboard"
69
+ end
70
+
71
+ unauthenticated do
72
+ get "/join", to: "home#join"
73
+ end
74
+
75
+ # Routes for constraints testing
76
+ devise_for :headquarters_admin, class_name: "Admin", path: "headquarters", constraints: {host: /192\.168\.1\.\d\d\d/}
77
+
78
+ constraints(host: /192\.168\.1\.\d\d\d/) do
79
+ devise_for :homebase_admin, class_name: "Admin", path: "homebase"
80
+ end
81
+
82
+ scope(subdomain: 'sub') do
83
+ devise_for :subdomain_users, class_name: "User", only: [:sessions]
84
+ end
85
+
86
+ devise_for :skip_admin, class_name: "Admin", skip: :all
87
+
88
+ # Routes for format=false testing
89
+ devise_for :htmlonly_admin, class_name: "Admin", skip: [:confirmations, :unlocks], path: "htmlonly_admin", format: false, skip_helpers: [:confirmations, :unlocks]
90
+ devise_for :htmlonly_users, class_name: "User", only: [:confirmations, :unlocks], path: "htmlonly_users", format: false, skip_helpers: true
91
+
92
+ # Other routes for routing_test.rb
93
+ devise_for :reader, class_name: "User", only: :passwords
94
+
95
+ scope host: "sub.example.com" do
96
+ devise_for :sub_admin, class_name: "Admin"
97
+ end
98
+
99
+ namespace :publisher, path_names: { sign_in: "i_dont_care", sign_out: "get_out" } do
100
+ devise_for :accounts, class_name: "Admin", path_names: { sign_in: "get_in" }
101
+ end
102
+
103
+ scope ":locale", module: :invalid do
104
+ devise_for :accounts, singular: "manager", class_name: "Admin",
105
+ path_names: {
106
+ sign_in: "login", sign_out: "logout",
107
+ password: "secret", confirmation: "verification",
108
+ unlock: "unblock", sign_up: "register",
109
+ registration: "management",
110
+ cancel: "giveup", edit: "edit/profile"
111
+ }, failure_app: lambda { |env| [404, {"Content-Type" => "text/plain"}, ["Oops, not found"]] }, module: :devise
112
+ end
113
+
114
+ namespace :sign_out_via, module: "devise" do
115
+ devise_for :deletes, sign_out_via: :delete, class_name: "Admin"
116
+ devise_for :posts, sign_out_via: :post, class_name: "Admin"
117
+ devise_for :gets, sign_out_via: :get, class_name: "Admin"
118
+ devise_for :delete_or_posts, sign_out_via: [:delete, :post], class_name: "Admin"
119
+ end
120
+
121
+ get "/set", to: "home#set"
122
+ get "/unauthenticated", to: "home#unauthenticated"
123
+ get "/custom_strategy/new"
124
+
125
+ root to: "home#index", via: [:get, :post]
126
+ end
@@ -0,0 +1,75 @@
1
+ superclass = ActiveRecord::Migration
2
+ # TODO: Inherit from the 5.0 Migration class directly when we drop support for Rails 4.
3
+ superclass = ActiveRecord::Migration[5.0] if superclass.respond_to?(:[])
4
+
5
+ class CreateTables < superclass
6
+ def self.up
7
+ create_table :users do |t|
8
+ t.string :username
9
+ t.string :facebook_token
10
+
11
+ ## Database authenticatable
12
+ t.string :email, null: false, default: ""
13
+ t.string :encrypted_password, null: false, default: ""
14
+
15
+ ## Recoverable
16
+ t.string :reset_password_token
17
+ t.datetime :reset_password_sent_at
18
+
19
+ ## Rememberable
20
+ t.datetime :remember_created_at
21
+
22
+ ## Trackable
23
+ t.integer :sign_in_count, default: 0
24
+ t.datetime :current_sign_in_at
25
+ t.datetime :last_sign_in_at
26
+ t.string :current_sign_in_ip
27
+ t.string :last_sign_in_ip
28
+
29
+ ## Confirmable
30
+ t.string :confirmation_token
31
+ t.datetime :confirmed_at
32
+ t.datetime :confirmation_sent_at
33
+ # t.string :unconfirmed_email # Only if using reconfirmable
34
+
35
+ ## Lockable
36
+ t.integer :failed_attempts, default: 0 # Only if lock strategy is :failed_attempts
37
+ t.string :unlock_token # Only if unlock strategy is :email or :both
38
+ t.datetime :locked_at
39
+
40
+ t.timestamps null: false
41
+ end
42
+
43
+ create_table :admins do |t|
44
+ ## Database authenticatable
45
+ t.string :email, null: true
46
+ t.string :encrypted_password, null: true
47
+
48
+ ## Recoverable
49
+ t.string :reset_password_token
50
+ t.datetime :reset_password_sent_at
51
+
52
+ ## Rememberable
53
+ t.datetime :remember_created_at
54
+
55
+ ## Confirmable
56
+ t.string :confirmation_token
57
+ t.datetime :confirmed_at
58
+ t.datetime :confirmation_sent_at
59
+ t.string :unconfirmed_email # Only if using reconfirmable
60
+
61
+ ## Lockable
62
+ t.datetime :locked_at
63
+
64
+ ## Attribute for testing route blocks
65
+ t.boolean :active, default: false
66
+
67
+ t.timestamps null: false
68
+ end
69
+ end
70
+
71
+ def self.down
72
+ drop_table :users
73
+ drop_table :admins
74
+ end
75
+ end
@@ -0,0 +1,55 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20100401102949) do
15
+
16
+ create_table "admins", force: true do |t|
17
+ t.string "email"
18
+ t.string "encrypted_password"
19
+ t.string "reset_password_token"
20
+ t.datetime "reset_password_sent_at"
21
+ t.datetime "remember_created_at"
22
+ t.string "confirmation_token"
23
+ t.datetime "confirmed_at"
24
+ t.datetime "confirmation_sent_at"
25
+ t.string "unconfirmed_email"
26
+ t.datetime "locked_at"
27
+ t.boolean "active", default: false
28
+ t.datetime "created_at"
29
+ t.datetime "updated_at"
30
+ end
31
+
32
+ create_table "users", force: true do |t|
33
+ t.string "username"
34
+ t.string "facebook_token"
35
+ t.string "email", default: "", null: false
36
+ t.string "encrypted_password", default: "", null: false
37
+ t.string "reset_password_token"
38
+ t.datetime "reset_password_sent_at"
39
+ t.datetime "remember_created_at"
40
+ t.integer "sign_in_count", default: 0
41
+ t.datetime "current_sign_in_at"
42
+ t.datetime "last_sign_in_at"
43
+ t.string "current_sign_in_ip"
44
+ t.string "last_sign_in_ip"
45
+ t.string "confirmation_token"
46
+ t.datetime "confirmed_at"
47
+ t.datetime "confirmation_sent_at"
48
+ t.integer "failed_attempts", default: 0
49
+ t.string "unlock_token"
50
+ t.datetime "locked_at"
51
+ t.datetime "created_at"
52
+ t.datetime "updated_at"
53
+ end
54
+
55
+ end
@@ -0,0 +1,17 @@
1
+ module SharedAdmin
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ devise :database_authenticatable, :registerable,
6
+ :timeoutable, :recoverable, :lockable, :confirmable,
7
+ unlock_strategy: :time, lock_strategy: :none,
8
+ allow_unconfirmed_access_for: 2.weeks, reconfirmable: true
9
+
10
+ validates_length_of :reset_password_token, minimum: 3, allow_blank: true
11
+ validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
12
+ end
13
+
14
+ def raw_confirmation_token
15
+ @raw_confirmation_token
16
+ end
17
+ end
@@ -0,0 +1,30 @@
1
+ module SharedUser
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ devise :database_authenticatable, :confirmable, :lockable, :recoverable,
6
+ :registerable, :rememberable, :timeoutable,
7
+ :trackable, :validatable, :omniauthable, password_length: 7..72,
8
+ reconfirmable: false
9
+
10
+ attr_accessor :other_key
11
+
12
+ # They need to be included after Devise is called.
13
+ extend ExtendMethods
14
+ end
15
+
16
+ def raw_confirmation_token
17
+ @raw_confirmation_token
18
+ end
19
+
20
+ module ExtendMethods
21
+ def new_with_session(params, session)
22
+ super.tap do |user|
23
+ if data = session["devise.facebook_data"]
24
+ user.email = data["email"]
25
+ user.confirmed_at = Time.now
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+ module SharedUserWithoutEmail
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ # NOTE: This is missing :validatable and :confirmable, as they both require
6
+ # an email field at the moment. It is also missing :omniauthable because that
7
+ # adds unnecessary complexity to the setup
8
+ devise :database_authenticatable, :lockable, :recoverable,
9
+ :registerable, :rememberable, :timeoutable,
10
+ :trackable
11
+ end
12
+
13
+ # This test stub is a bit rubbish because it's tied very closely to the
14
+ # implementation where we care about this one case. However, completely
15
+ # removing the email field breaks "recoverable" tests completely, so we are
16
+ # just taking the approach here that "email" is something that is a not an
17
+ # ActiveRecord field.
18
+ def email_changed?
19
+ raise NoMethodError
20
+ end
21
+
22
+ def respond_to?(method_name, include_all=false)
23
+ return false if method_name.to_sym == :email_changed?
24
+ super(method_name, include_all)
25
+ end
26
+ end
@@ -0,0 +1,13 @@
1
+ module SharedUserWithoutOmniauth
2
+ extend ActiveSupport::Concern
3
+
4
+ included do
5
+ devise :database_authenticatable, :confirmable, :lockable, :recoverable,
6
+ :registerable, :rememberable, :timeoutable,
7
+ :trackable, :validatable, reconfirmable: false
8
+ end
9
+
10
+ def raw_confirmation_token
11
+ @raw_confirmation_token
12
+ end
13
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ <p>We've been notified about this issue and we'll take a look at it shortly.</p>
24
+ </div>
25
+ </body>
26
+ </html>