Skip to content

Commit

Permalink
Add basic authentication to production mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
yamat47 committed Aug 12, 2024
1 parent 3121cba commit d5a562c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
5 changes: 5 additions & 0 deletions app/app/controllers/admin/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

module Admin
class ApplicationController < ::ApplicationController
if Rails.env.production?
http_basic_authenticate_with(name: ENV.fetch('ADMIN_BASIC_AUTH_NAME'),
password: ENV.fetch('ADMIN_BASIC_AUTH_PASSWORD'))
end

layout 'admin/application'

before_action :check_logged_in
Expand Down
3 changes: 3 additions & 0 deletions environments/development/.app-env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ FILE_AWS_S3_BUCKET: dev-kcff-activestorage
FILE_AWS_S3_ENDPOINT: http://minio.127.0.0.1.nip.io:9000
FILE_AWS_ACCESS_KEY_ID: minio
FILE_AWS_SECRET_ACCESS_KEY: password

ADMIN_BASIC_AUTH_NAME=
ADMIN_BASIC_AUTH_PASSWORD=

0 comments on commit d5a562c

Please sign in to comment.