Skip to content

Commit c1a66bc

Browse files
committed
Add basic auth to government frontend review app
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.
1 parent 38dc142 commit c1a66bc

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app.json

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@
2525
},
2626
"HEROKU_APP_NAME": {
2727
"required": true
28-
}
28+
},
29+
"BASIC_AUTH_USERNAME": {
30+
"required": true
31+
},
32+
"BASIC_AUTH_PASSWORD": {
33+
"required": true
34+
},
35+
"REQUIRE_BASIC_AUTH": "true"
2936
},
3037
"image": "heroku/ruby",
3138
"buildpacks": [

app/controllers/application_controller.rb

+8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@ class ApplicationController < ActionController::Base
33
# For APIs, you may want to use :null_session instead.
44
protect_from_forgery except: :service_sign_in_options
55

6+
7+
if ENV["BASIC_AUTH_USERNAME"]
8+
http_basic_authenticate_with(
9+
name: ENV.fetch("BASIC_AUTH_USERNAME"),
10+
password: ENV.fetch("BASIC_AUTH_PASSWORD")
11+
)
12+
end
13+
614
private
715

816
def content_item_path

0 commit comments

Comments
 (0)