Skip to content

Commit

Permalink
Add basic auth to government frontend review app
Browse files Browse the repository at this point in the history
This has been lifted from [Collections](https://github.com/alphagov/collections/blob/master/app/controllers/application_controller.rb#L11-L16)

The env variables have been added to government-frontend.herokuapp.com already.

This is to prevent users from accidentally landing on a page in the review
app and believing that it's GOV.UK.
  • Loading branch information
sihugh committed Sep 13, 2019
1 parent 38dc142 commit c1a66bc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
9 changes: 8 additions & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,14 @@
},
"HEROKU_APP_NAME": {
"required": true
}
},
"BASIC_AUTH_USERNAME": {
"required": true
},
"BASIC_AUTH_PASSWORD": {
"required": true
},
"REQUIRE_BASIC_AUTH": "true"
},
"image": "heroku/ruby",
"buildpacks": [
Expand Down
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ class ApplicationController < ActionController::Base
# For APIs, you may want to use :null_session instead.
protect_from_forgery except: :service_sign_in_options


if ENV["BASIC_AUTH_USERNAME"]
http_basic_authenticate_with(
name: ENV.fetch("BASIC_AUTH_USERNAME"),
password: ENV.fetch("BASIC_AUTH_PASSWORD")
)
end

private

def content_item_path
Expand Down

0 comments on commit c1a66bc

Please sign in to comment.