Skip to content

Commit

Permalink
Make --authentication=none the same as --with-authentication=false
Browse files Browse the repository at this point in the history
It seemed smart to have `--authentication=none` allow to browse the
store (including /admin) without needing to sign in.

Turned out that the dummy app uses it and extensions rely on the
absence of authentication. Reverting to the previous behavior will
fix the CI of a number of extensions.
  • Loading branch information
elia committed Oct 12, 2022
1 parent 1ccec1e commit d6c59a6
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 35 deletions.
3 changes: 1 addition & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -211,9 +211,8 @@ jobs:

- install_solidus: { flags: "--sample=false --frontend=none --authentication=none" }
- test_page: { expected_text: "<title>Ruby on Rails" }
- test_page: { path: '/admin/orders', expected_text: "No Orders found." }

- install_solidus: { flags: "--sample=false --frontend=solidus_frontend --authentication=none" }
- install_solidus: { flags: "--sample=false --frontend=solidus_frontend --authentication=custom" }
- test_page: { expected_text: "data-hook=" }

- install_solidus: { flags: "--sample=false --frontend=solidus_starter_frontend --authentication=devise" }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
initializer 'spree_authentication.rb', <<~RUBY
# Please replace this module with your own implementation of
# ApplicationController#spree_current_user.
#
# The current setup will allow doing guest checkouts.
ActiveSupport.on_load(:action_controller) do
def spree_current_user
# Define here your custom logic for retrieving the current user
nil
end
end
# Re-raise the original authorization error on anauthorized access
Rails.application.config.to_prepare do
Spree::BaseController.unauthorized_redirect = -> { raise "Define the behavior for unauthorized access in \#{__FILE__}." }
end
RUBY

create_file 'app/views/spree/admin/shared/_navigation_footer.html.erb', <<~ERB
<!-- Add here your login/logout links in 'app/views/spree/admin/shared/_navigation_footer.html.erb'. -->
ERB
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
initializer 'spree_no_authentication.rb', <<~RUBY
# Please replace this module with your own implementation of
# ApplicationController#spree_current_user.
#
# The current setup will allow doing guest checkouts and visitng
# the /admin area without requiring any authentication.
module SpreeNoAuthentication
def self.install!
# Set #spree_current_user to nil for all controllers
ActiveSupport.on_load(:action_controller) do
def spree_current_user
nil
end
end
# Re-raise the original authorization error on anauthorized access
Rails.application.config.to_prepare do
Spree::BaseController.unauthorized_redirect = -> { raise }
end
# Provide the "default" role with full permissions on everything
Spree.config do |config|
config.roles.assign_permissions :default, ['Spree::PermissionSets::SuperUser']
end
end
install!
end
RUBY

create_file 'app/views/spree/admin/shared/_navigation_footer.html.erb', ''
# noop
5 changes: 3 additions & 2 deletions core/lib/generators/solidus/install/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,10 @@ class InstallGenerator < Rails::Generators::AppBase

DEFAULT_AUTHENTICATION = 'devise'
AUTHENTICATIONS = {
'none' => "#{__dir__}/app_templates/authentication/none.rb",
'existing' => "#{__dir__}/app_templates/authentication/existing.rb",
'devise' => "#{__dir__}/app_templates/authentication/devise.rb",
'existing' => "#{__dir__}/app_templates/authentication/existing.rb",
'custom' => "#{__dir__}/app_templates/authentication/custom.rb",
'none' => "#{__dir__}/app_templates/authentication/none.rb",
}

class_option :migrate, type: :boolean, default: true, banner: 'Run Solidus migrations'
Expand Down

0 comments on commit d6c59a6

Please sign in to comment.