From 343ac49227933a2f53e640ec3a545d6cb0817d5b Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Thu, 20 Oct 2022 16:46:33 -0400 Subject: [PATCH 1/7] Rename `Devise::Strategies::Authenticatable => PasswordAuthenticatable` * To begin the process of refactoring Devise to support passkeys, we need to decouple authentication from being specifically tied to passwords. * The first step is explicitly prefixing generically-named components like `Authenticatable` with `Password`, since they concern password authentication --- lib/devise.rb | 2 +- lib/devise/strategies/database_authenticatable.rb | 4 ++-- .../{authenticatable.rb => password_authenticatable.rb} | 2 +- lib/devise/strategies/rememberable.rb | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename lib/devise/strategies/{authenticatable.rb => password_authenticatable.rb} (99%) diff --git a/lib/devise.rb b/lib/devise.rb index ede8038679..c55a2da880 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -39,7 +39,7 @@ module Mailers module Strategies autoload :Base, 'devise/strategies/base' - autoload :Authenticatable, 'devise/strategies/authenticatable' + autoload :PasswordAuthenticatable, 'devise/strategies/password_authenticatable' end module Test diff --git a/lib/devise/strategies/database_authenticatable.rb b/lib/devise/strategies/database_authenticatable.rb index f7e007d144..1f42922531 100644 --- a/lib/devise/strategies/database_authenticatable.rb +++ b/lib/devise/strategies/database_authenticatable.rb @@ -1,11 +1,11 @@ # frozen_string_literal: true -require 'devise/strategies/authenticatable' +require 'devise/strategies/password_authenticatable' module Devise module Strategies # Default strategy for signing in a user, based on their email and password in the database. - class DatabaseAuthenticatable < Authenticatable + class DatabaseAuthenticatable < PasswordAuthenticatable def authenticate! resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash) hashed = false diff --git a/lib/devise/strategies/authenticatable.rb b/lib/devise/strategies/password_authenticatable.rb similarity index 99% rename from lib/devise/strategies/authenticatable.rb rename to lib/devise/strategies/password_authenticatable.rb index 2af7a741cf..7ed0ce6594 100644 --- a/lib/devise/strategies/authenticatable.rb +++ b/lib/devise/strategies/password_authenticatable.rb @@ -7,7 +7,7 @@ module Strategies # This strategy should be used as basis for authentication strategies. It retrieves # parameters both from params or from http authorization headers. See database_authenticatable # for an example. - class Authenticatable < Base + class PasswordAuthenticatable < Base attr_accessor :authentication_hash, :authentication_type, :password def store? diff --git a/lib/devise/strategies/rememberable.rb b/lib/devise/strategies/rememberable.rb index fe20804f68..723add614b 100644 --- a/lib/devise/strategies/rememberable.rb +++ b/lib/devise/strategies/rememberable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'devise/strategies/authenticatable' +require 'devise/strategies/password_authenticatable' module Devise module Strategies @@ -8,7 +8,7 @@ module Strategies # to verify whether there is a cookie with the remember token, and to # recreate the user from this cookie if it exists. Must be called *before* # authenticatable. - class Rememberable < Authenticatable + class Rememberable < PasswordAuthenticatable # A valid strategy for rememberable needs a remember token in the cookies. def valid? @remember_cookie = nil From 6fbca116472b213ae358ffefc7bcaa99c79c5f10 Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Thu, 20 Oct 2022 16:51:57 -0400 Subject: [PATCH 2/7] Add `Devise::Strategies::Authenticatable` shim w/ deprecation warning * To maintain compatability with exisiting installations, we need the `Devise::Strategies::Authenticatable` class. * This re-adds the class in, subclassing from `PasswordAuthenticable` and printing a deprecation warning --- lib/devise.rb | 1 + lib/devise/strategies/authenticatable.rb | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 lib/devise/strategies/authenticatable.rb diff --git a/lib/devise.rb b/lib/devise.rb index c55a2da880..0971e78e97 100644 --- a/lib/devise.rb +++ b/lib/devise.rb @@ -40,6 +40,7 @@ module Mailers module Strategies autoload :Base, 'devise/strategies/base' autoload :PasswordAuthenticatable, 'devise/strategies/password_authenticatable' + autoload :Authenticatable, 'devise/strategies/authenticatable' end module Test diff --git a/lib/devise/strategies/authenticatable.rb b/lib/devise/strategies/authenticatable.rb new file mode 100644 index 0000000000..84d04ded0b --- /dev/null +++ b/lib/devise/strategies/authenticatable.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'devise/strategies/password_authenticatable' + +module Devise + module Strategies + class Authenticatable < PasswordAuthenticatable + ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + [Devise] `Devise::Strategies::Authenticatable` is deprecated and will be + removed in the next major version. + Use `Devise::Strategies::PasswordAuthenticatable` instead. + DEPRECATION + end + end +end \ No newline at end of file From f577537d1999e8fe53f3dbe28f0290693484bd85 Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Wed, 26 Oct 2022 20:16:49 -0400 Subject: [PATCH 3/7] Add `.DS_Store` to `.gitignore` --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index ac2a95781c..71aec37b11 100644 --- a/.gitignore +++ b/.gitignore @@ -9,3 +9,4 @@ pkg log test/tmp/* gemfiles/*.lock +.DS_Store \ No newline at end of file From cf0afca9a99d48996f0fb3ea3ecf67849d7a7383 Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Wed, 26 Oct 2022 20:20:21 -0400 Subject: [PATCH 4/7] Rename `DatabaseAuthenticatable`=>`DatabasePasswordAuthenticatable` * To begin the process of refactoring Devise to support passkeys, we need to decouple authentication from being specifically tied to passwords. * The first step is explicitly prefixing generically-named components like `Authenticatable` with `Password`, since they concern password authentication --- lib/devise/models/database_authenticatable.rb | 2 +- ...uthenticatable.rb => database_password_authenticatable.rb} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename lib/devise/strategies/{database_authenticatable.rb => database_password_authenticatable.rb} (91%) diff --git a/lib/devise/models/database_authenticatable.rb b/lib/devise/models/database_authenticatable.rb index 8c0e22613d..c8d7abf520 100644 --- a/lib/devise/models/database_authenticatable.rb +++ b/lib/devise/models/database_authenticatable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'devise/strategies/database_authenticatable' +require 'devise/strategies/database_password_authenticatable' module Devise module Models diff --git a/lib/devise/strategies/database_authenticatable.rb b/lib/devise/strategies/database_password_authenticatable.rb similarity index 91% rename from lib/devise/strategies/database_authenticatable.rb rename to lib/devise/strategies/database_password_authenticatable.rb index 1f42922531..04357944af 100644 --- a/lib/devise/strategies/database_authenticatable.rb +++ b/lib/devise/strategies/database_password_authenticatable.rb @@ -5,7 +5,7 @@ module Devise module Strategies # Default strategy for signing in a user, based on their email and password in the database. - class DatabaseAuthenticatable < PasswordAuthenticatable + class DatabasePasswordAuthenticatable < PasswordAuthenticatable def authenticate! resource = password.present? && mapping.to.find_for_database_authentication(authentication_hash) hashed = false @@ -28,4 +28,4 @@ def authenticate! end end -Warden::Strategies.add(:database_authenticatable, Devise::Strategies::DatabaseAuthenticatable) +Warden::Strategies.add(:database_authenticatable, Devise::Strategies::DatabasePasswordAuthenticatable) From ea157bb68ba86127afdce4a60951131cd43d16bc Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Wed, 26 Oct 2022 20:22:41 -0400 Subject: [PATCH 5/7] `Devise::Strategies::DatabaseAuthenticatable` shim w/ warning * To maintain compatability with exisiting installations, we need the `Devise::Strategies::DatabaseAuthenticatable` class. * This re-adds the class in, subclassing from `DatabasePasswordAuthenticable` and printing a deprecation warning --- lib/devise/strategies/database_authenticatable.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/devise/strategies/database_authenticatable.rb diff --git a/lib/devise/strategies/database_authenticatable.rb b/lib/devise/strategies/database_authenticatable.rb new file mode 100644 index 0000000000..6b3b1413f5 --- /dev/null +++ b/lib/devise/strategies/database_authenticatable.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'devise/strategies/database_password_authenticatable' + +module Devise + module Strategies + class DatabaseAuthenticatable < DatabasePasswordAuthenticatable + ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + [Devise] `Devise::Strategies::DatabaseAuthenticatable` is deprecated and will be + removed in the next major version. + Use `Devise::Strategies::DatabasePasswordAuthenticatable` instead. + DEPRECATION + end + end +end \ No newline at end of file From 261db02cc51fb02d01f02d70669e946815a5114d Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Wed, 26 Oct 2022 20:24:46 -0400 Subject: [PATCH 6/7] Rename `Rememberable`=>`PasswordRememberable` * To begin the process of refactoring Devise to support passkeys, we need to decouple authentication from being specifically tied to passwords. * The first step is explicitly prefixing generically-named components like `Authenticatable` with `Password`, since they concern password authentication --- lib/devise/models/rememberable.rb | 2 +- .../strategies/{rememberable.rb => password_rememberable.rb} | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) rename lib/devise/strategies/{rememberable.rb => password_rememberable.rb} (93%) diff --git a/lib/devise/models/rememberable.rb b/lib/devise/models/rememberable.rb index a66979ad59..d137cf5246 100644 --- a/lib/devise/models/rememberable.rb +++ b/lib/devise/models/rememberable.rb @@ -1,6 +1,6 @@ # frozen_string_literal: true -require 'devise/strategies/rememberable' +require 'devise/strategies/password_rememberable' require 'devise/hooks/rememberable' require 'devise/hooks/forgetable' diff --git a/lib/devise/strategies/rememberable.rb b/lib/devise/strategies/password_rememberable.rb similarity index 93% rename from lib/devise/strategies/rememberable.rb rename to lib/devise/strategies/password_rememberable.rb index 723add614b..aefb067a35 100644 --- a/lib/devise/strategies/rememberable.rb +++ b/lib/devise/strategies/password_rememberable.rb @@ -8,7 +8,7 @@ module Strategies # to verify whether there is a cookie with the remember token, and to # recreate the user from this cookie if it exists. Must be called *before* # authenticatable. - class Rememberable < PasswordAuthenticatable + class PasswordRememberable < PasswordAuthenticatable # A valid strategy for rememberable needs a remember token in the cookies. def valid? @remember_cookie = nil @@ -64,4 +64,4 @@ def remember_cookie end end -Warden::Strategies.add(:rememberable, Devise::Strategies::Rememberable) +Warden::Strategies.add(:rememberable, Devise::Strategies::PasswordRememberable) From 0cf0440d802c293cb4d292c1d764a01eb49b949b Mon Sep 17 00:00:00 2001 From: Thomas Cannon Date: Wed, 26 Oct 2022 20:26:46 -0400 Subject: [PATCH 7/7] Add `Devise::Strategies::Rememberable` shim w/ deprecation warning * To maintain compatability with exisiting installations, we need the `Devise::Strategies::Rememberable` class. * This re-adds the class in, subclassing from `PasswordRememberable` and printing a deprecation warning --- lib/devise/strategies/rememberable.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 lib/devise/strategies/rememberable.rb diff --git a/lib/devise/strategies/rememberable.rb b/lib/devise/strategies/rememberable.rb new file mode 100644 index 0000000000..7425dc743d --- /dev/null +++ b/lib/devise/strategies/rememberable.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +require 'devise/strategies/password_rememberable' + +module Devise + module Strategies + class Rememberable < PasswordRememberable + ActiveSupport::Deprecation.warn <<-DEPRECATION.strip_heredoc + [Devise] `Devise::Strategies::Rememberable` is deprecated and will be + removed in the next major version. + Use `Devise::Strategies::PasswordRememberable` instead. + DEPRECATION + end + end +end \ No newline at end of file