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
@@ -1,3 +1,3 @@
1
1
  module DeviseOpenidAuthenticatable
2
- VERSION = "1.2.1"
2
+ VERSION = "1.3.0"
3
3
  end
data/rails/Rakefile ADDED
@@ -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,6 @@
1
+ require 'shared_admin'
2
+
3
+ class Admin < ActiveRecord::Base
4
+ include Shim
5
+ include SharedAdmin
6
+ end
@@ -0,0 +1,2 @@
1
+ module Shim
2
+ end
@@ -0,0 +1,7 @@
1
+ require 'shared_user'
2
+
3
+ class User < ActiveRecord::Base
4
+ include Shim
5
+ include SharedUser
6
+ include ActiveModel::Serializers::Xml if Devise.rails5?
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'shared_user_without_omniauth'
2
+
3
+ class UserOnEngine < ActiveRecord::Base
4
+ self.table_name = 'users'
5
+ include Shim
6
+ include SharedUserWithoutOmniauth
7
+ end
@@ -0,0 +1,7 @@
1
+ require 'shared_user_without_omniauth'
2
+
3
+ class UserOnMainApp < ActiveRecord::Base
4
+ self.table_name = 'users'
5
+ include Shim
6
+ include SharedUserWithoutOmniauth
7
+ end
@@ -0,0 +1,8 @@
1
+ require "shared_user_without_email"
2
+
3
+ class UserWithoutEmail < ActiveRecord::Base
4
+ self.table_name = 'users'
5
+ include Shim
6
+ include SharedUserWithoutEmail
7
+ end
8
+
@@ -0,0 +1,6 @@
1
+ class Admins::SessionsController < Devise::SessionsController
2
+ def new
3
+ flash[:special] = "Welcome to #{controller_path.inspect} controller!"
4
+ super
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class AdminsController < ApplicationController
2
+ before_action :authenticate_admin!
3
+
4
+ def index
5
+ end
6
+ end
@@ -0,0 +1,11 @@
1
+ # Filters added to this controller apply to all controllers in the application.
2
+ # Likewise, all the methods added will be available for all controllers.
3
+
4
+ class ApplicationController < ActionController::Base
5
+ protect_from_forgery
6
+ before_action :current_user, unless: :devise_controller?
7
+ before_action :authenticate_user!, if: :devise_controller?
8
+ respond_to(*Mime::SET.map(&:to_sym))
9
+
10
+ devise_group :commenter, contains: [:user, :admin]
11
+ end
@@ -0,0 +1,30 @@
1
+ class ApplicationWithFakeEngine < ApplicationController
2
+ private
3
+
4
+ helper_method :fake_engine
5
+ def fake_engine
6
+ @fake_engine ||= FakeEngine.new
7
+ end
8
+ end
9
+
10
+ class FakeEngine
11
+ def user_on_engine_confirmation_path
12
+ '/user_on_engine/confirmation'
13
+ end
14
+
15
+ def new_user_on_engine_session_path
16
+ '/user_on_engine/confirmation/new'
17
+ end
18
+
19
+ def new_user_on_engine_registration_path
20
+ '/user_on_engine/registration/new'
21
+ end
22
+
23
+ def new_user_on_engine_password_path
24
+ '/user_on_engine/password/new'
25
+ end
26
+
27
+ def new_user_on_engine_unlock_path
28
+ '/user_on_engine/unlock/new'
29
+ end
30
+ end
@@ -0,0 +1,31 @@
1
+ class Custom::RegistrationsController < Devise::RegistrationsController
2
+ def new
3
+ super do |resource|
4
+ @new_block_called = true
5
+ end
6
+ end
7
+
8
+ def create
9
+ super do |resource|
10
+ @create_block_called = true
11
+ end
12
+ end
13
+
14
+ def update
15
+ super do |resource|
16
+ @update_block_called = true
17
+ end
18
+ end
19
+
20
+ def create_block_called?
21
+ @create_block_called == true
22
+ end
23
+
24
+ def update_block_called?
25
+ @update_block_called == true
26
+ end
27
+
28
+ def new_block_called?
29
+ @new_block_called == true
30
+ end
31
+ end
@@ -0,0 +1,29 @@
1
+ class HomeController < ApplicationController
2
+ def index
3
+ end
4
+
5
+ def private
6
+ end
7
+
8
+ def user_dashboard
9
+ end
10
+
11
+ def admin_dashboard
12
+ end
13
+
14
+ def join
15
+ end
16
+
17
+ def set
18
+ session["devise.foo_bar"] = "something"
19
+ head :ok
20
+ end
21
+
22
+ def unauthenticated
23
+ if Devise.rails5?
24
+ render body: "unauthenticated", status: :unauthorized
25
+ else
26
+ render text: "unauthenticated", status: :unauthorized
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::RegistrationsController < ApplicationController
2
+ end
@@ -0,0 +1,2 @@
1
+ class Publisher::SessionsController < ApplicationController
2
+ end
@@ -0,0 +1,14 @@
1
+ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
2
+ def facebook
3
+ data = request.respond_to?(:get_header) ? request.get_header("omniauth.auth") : request.env["omniauth.auth"]
4
+ session["devise.facebook_data"] = data["extra"]["user_hash"]
5
+ render json: data
6
+ end
7
+
8
+ def sign_in_facebook
9
+ user = User.to_adapter.find_first(email: 'user@test.com')
10
+ user.remember_me = true
11
+ sign_in user
12
+ render (Devise.rails5? ? :body : :text) => ""
13
+ end
14
+ end
@@ -0,0 +1,31 @@
1
+ class UsersController < ApplicationController
2
+ prepend_before_action :current_user, only: :exhibit
3
+ before_action :authenticate_user!, except: [:accept, :exhibit]
4
+ respond_to :html, :xml
5
+
6
+ def index
7
+ user_session[:cart] = "Cart"
8
+ respond_with(current_user)
9
+ end
10
+
11
+ def edit_form
12
+ user_session['last_request_at'] = params.fetch(:last_request_at, 31.minutes.ago.utc)
13
+ end
14
+
15
+ def update_form
16
+ render (Devise.rails5? ? :body : :text) => 'Update'
17
+ end
18
+
19
+ def accept
20
+ @current_user = current_user
21
+ end
22
+
23
+ def exhibit
24
+ render (Devise.rails5? ? :body : :text) => current_user ? "User is authenticated" : "User is not authenticated"
25
+ end
26
+
27
+ def expire
28
+ user_session['last_request_at'] = 31.minutes.ago.utc
29
+ render (Devise.rails5? ? :body : :text) => 'User will be expired on next request'
30
+ end
31
+ end
@@ -0,0 +1,3 @@
1
+ # Methods added to this helper will be available to all templates in the application.
2
+ module ApplicationHelper
3
+ end
@@ -0,0 +1,3 @@
1
+ class Users::FromProcMailer < Devise::Mailer
2
+ default from: proc { 'custom@example.com' }
3
+ end
@@ -0,0 +1,3 @@
1
+ class Users::Mailer < Devise::Mailer
2
+ default from: 'custom@example.com'
3
+ end
@@ -0,0 +1,4 @@
1
+ class Users::ReplyToMailer < Devise::Mailer
2
+ default from: 'custom@example.com'
3
+ default reply_to: 'custom_reply_to@example.com'
4
+ end
@@ -0,0 +1,29 @@
1
+ require 'shared_admin'
2
+
3
+ class Admin
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedAdmin
7
+
8
+ ## Database authenticatable
9
+ field :email, type: String
10
+ field :encrypted_password, type: String
11
+
12
+ ## Recoverable
13
+ field :reset_password_token, type: String
14
+ field :reset_password_sent_at, type: Time
15
+
16
+ ## Rememberable
17
+ field :remember_created_at, type: Time
18
+
19
+ ## Confirmable
20
+ field :confirmation_token, type: String
21
+ field :confirmed_at, type: Time
22
+ field :confirmation_sent_at, type: Time
23
+ field :unconfirmed_email, type: String # Only if using reconfirmable
24
+
25
+ ## Lockable
26
+ field :locked_at, type: Time
27
+
28
+ field :active, type: Boolean, default: false
29
+ end
@@ -0,0 +1,23 @@
1
+ module Shim
2
+ extend ::ActiveSupport::Concern
3
+
4
+ included do
5
+ include ::Mongoid::Timestamps
6
+ field :created_at, type: DateTime
7
+ end
8
+
9
+ module ClassMethods
10
+ def order(attribute)
11
+ asc(attribute)
12
+ end
13
+
14
+ def find_by_email(email)
15
+ find_by(email: email)
16
+ end
17
+ end
18
+
19
+ # overwrite equality (because some devise tests use this for asserting model equality)
20
+ def ==(other)
21
+ other.is_a?(self.class) && _id == other._id
22
+ end
23
+ end
@@ -0,0 +1,39 @@
1
+ require 'shared_user'
2
+
3
+ class User
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedUser
7
+
8
+ field :username, type: String
9
+ field :facebook_token, type: String
10
+
11
+ ## Database authenticatable
12
+ field :email, type: String, default: ""
13
+ field :encrypted_password, type: String, default: ""
14
+
15
+ ## Recoverable
16
+ field :reset_password_token, type: String
17
+ field :reset_password_sent_at, type: Time
18
+
19
+ ## Rememberable
20
+ field :remember_created_at, type: Time
21
+
22
+ ## Trackable
23
+ field :sign_in_count, type: Integer, default: 0
24
+ field :current_sign_in_at, type: Time
25
+ field :last_sign_in_at, type: Time
26
+ field :current_sign_in_ip, type: String
27
+ field :last_sign_in_ip, type: String
28
+
29
+ ## Confirmable
30
+ field :confirmation_token, type: String
31
+ field :confirmed_at, type: Time
32
+ field :confirmation_sent_at, type: Time
33
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
34
+
35
+ ## Lockable
36
+ field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
37
+ field :unlock_token, type: String # Only if unlock strategy is :email or :both
38
+ field :locked_at, type: Time
39
+ end
@@ -0,0 +1,39 @@
1
+ require 'shared_user_without_omniauth'
2
+
3
+ class UserOnEngine
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedUserWithoutOmniauth
7
+
8
+ field :username, type: String
9
+ field :facebook_token, type: String
10
+
11
+ ## Database authenticatable
12
+ field :email, type: String, default: ""
13
+ field :encrypted_password, type: String, default: ""
14
+
15
+ ## Recoverable
16
+ field :reset_password_token, type: String
17
+ field :reset_password_sent_at, type: Time
18
+
19
+ ## Rememberable
20
+ field :remember_created_at, type: Time
21
+
22
+ ## Trackable
23
+ field :sign_in_count, type: Integer, default: 0
24
+ field :current_sign_in_at, type: Time
25
+ field :last_sign_in_at, type: Time
26
+ field :current_sign_in_ip, type: String
27
+ field :last_sign_in_ip, type: String
28
+
29
+ ## Confirmable
30
+ field :confirmation_token, type: String
31
+ field :confirmed_at, type: Time
32
+ field :confirmation_sent_at, type: Time
33
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
34
+
35
+ ## Lockable
36
+ field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
37
+ field :unlock_token, type: String # Only if unlock strategy is :email or :both
38
+ field :locked_at, type: Time
39
+ end
@@ -0,0 +1,39 @@
1
+ require 'shared_user_without_omniauth'
2
+
3
+ class UserOnMainApp
4
+ include Mongoid::Document
5
+ include Shim
6
+ include SharedUserWithoutOmniauth
7
+
8
+ field :username, type: String
9
+ field :facebook_token, type: String
10
+
11
+ ## Database authenticatable
12
+ field :email, type: String, default: ""
13
+ field :encrypted_password, type: String, default: ""
14
+
15
+ ## Recoverable
16
+ field :reset_password_token, type: String
17
+ field :reset_password_sent_at, type: Time
18
+
19
+ ## Rememberable
20
+ field :remember_created_at, type: Time
21
+
22
+ ## Trackable
23
+ field :sign_in_count, type: Integer, default: 0
24
+ field :current_sign_in_at, type: Time
25
+ field :last_sign_in_at, type: Time
26
+ field :current_sign_in_ip, type: String
27
+ field :last_sign_in_ip, type: String
28
+
29
+ ## Confirmable
30
+ field :confirmation_token, type: String
31
+ field :confirmed_at, type: Time
32
+ field :confirmation_sent_at, type: Time
33
+ # field :unconfirmed_email, type: String # Only if using reconfirmable
34
+
35
+ ## Lockable
36
+ field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
37
+ field :unlock_token, type: String # Only if unlock strategy is :email or :both
38
+ field :locked_at, type: Time
39
+ end