Skip to content

Commit

Permalink
Add basic auth
Browse files Browse the repository at this point in the history
For now this uses the SUPPORT_USERNAME/PASSWORD env vars.
  • Loading branch information
steventux committed Jul 12, 2023
1 parent a5f0b4d commit a1d7bbf
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
class ApplicationController < ActionController::Base
default_form_builder(GOVUKDesignSystemFormBuilder::FormBuilder)

before_action :authenticate

def authenticate
valid_credentials = [
{
username: ENV.fetch("SUPPORT_USERNAME", "support"),
password: ENV.fetch("SUPPORT_PASSWORD", "support"),
},
]

authenticate_or_request_with_http_basic do |username, password|
valid_credentials.include?({ username:, password: })
end
end
end

0 comments on commit a1d7bbf

Please sign in to comment.