Skip to content

Commit ae1dcc4

Browse files
committed
Stop sending API key with API requests
forms-admin does not require an API key for requests as the /api/ endpoints are only accessible from within the VPC in our deployed environments. Stop sending the API key with requests and remove the configuration setting as forms-runner now makes requests to forms-admin rather than forms-api.
1 parent f475b0d commit ae1dcc4

24 files changed

+26
-167
lines changed

.review_apps/ecs_task_definition.tf

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ locals {
2222
{ name = "SETTINGS__ANALYTICS_ENABLED", value = "false" },
2323
{ name = "SETTINGS__CLOUDWATCH_METRICS_ENABLED", value = "false" },
2424
{ name = "SETTINGS__FORMS_ADMIN__BASE_URL", value = "https://${local.admin_app_hostname}" },
25-
{ name = "SETTINGS__FORMS_API__AUTH_KEY", value = "unsecured_api_key_for_review_apps_only" },
2625
{ name = "SETTINGS__FORMS_API__BASE_URL", value = "http://localhost:9292" },
2726
{ name = "SETTINGS__FORMS_ENV", value = "review" },
2827

@@ -40,7 +39,6 @@ locals {
4039
{ name = "RAILS_DEVELOPMENT_HOSTS", value = "localhost:9292" },
4140
{ name = "RAILS_ENV", value = "production" },
4241
{ name = "SECRET_KEY_BASE", value = "unsecured_secret_key_material" },
43-
{ name = "SETTINGS__FORMS_API__AUTH_KEY", value = "unsecured_api_key_for_review_apps_only" },
4442
{ name = "SETTINGS__FORMS_ENV", value = "review" },
4543
]
4644

app/resources/api/v2/form_document_resource.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ class Api::V2::FormDocumentResource < ActiveResource::Base
33
self.site = Settings.forms_api.base_url
44
self.prefix = "/api/v2/"
55
self.include_format_in_path = false
6-
headers["X-API-Token"] = Settings.forms_api.auth_key
76

87
class Step < ActiveResource::Base
98
self.site = Settings.forms_api.base_url

config/settings.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ forms_admin:
66
base_url: http://localhost:3000
77

88
forms_api:
9-
# Authentication key to authenticate forms-runner to forms-api
10-
auth_key: development_key
119
# URL to form-admin API endpoints
1210
base_url: http://localhost:3000
1311

spec/config/settings_spec.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
describe ".forms_api" do
3030
forms_api = settings[:forms_api]
3131

32-
include_examples expected_value_test, :auth_key, forms_api, "development_key"
3332
include_examples expected_value_test, :base_url, forms_api, "http://localhost:3000"
3433
end
3534

spec/features/email_confirmation_spec.rb

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,8 @@
66
let(:question_text) { Faker::Lorem.question }
77
let(:text_answer) { Faker::Lorem.sentence }
88

9-
let(:req_headers) do
10-
{
11-
"X-API-Token" => Settings.forms_api.auth_key,
12-
"Accept" => "application/json",
13-
}
14-
end
15-
let(:post_headers) do
16-
{
17-
"X-API-Token" => Settings.forms_api.auth_key,
18-
"Content-Type" => "application/json",
19-
}
20-
end
9+
let(:req_headers) { { "Accept" => "application/json" } }
10+
let(:post_headers) { { "Content-Type" => "application/json" } }
2111

2212
before do
2313
ActiveResource::HttpMock.respond_to do |mock|

spec/features/fill_in_and_submit_form_spec.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,8 @@
77
let(:answer_text) { "Answer text" }
88
let(:reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase }
99

10-
let(:req_headers) do
11-
{
12-
"X-API-Token" => Settings.forms_api.auth_key,
13-
"Accept" => "application/json",
14-
}
15-
end
16-
17-
let(:post_headers) do
18-
{
19-
"X-API-Token" => Settings.forms_api.auth_key,
20-
"Content-Type" => "application/json",
21-
}
22-
end
10+
let(:req_headers) { { "Accept" => "application/json" } }
11+
let(:post_headers) { { "Content-Type" => "application/json" } }
2312

2413
before do
2514
ActiveResource::HttpMock.respond_to do |mock|

spec/features/fill_in_and_submit_form_with_csv_spec.rb

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,7 @@
99
end
1010
let(:form) { build :v2_form_document, :live?, id: 1, name: "Fill in this form", steps:, start_page: steps.first.id, submission_type: "email_with_csv" }
1111
let(:reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase }
12-
let(:req_headers) do
13-
{
14-
"X-API-Token" => Settings.forms_api.auth_key,
15-
"Accept" => "application/json",
16-
}
17-
end
12+
let(:req_headers) { { "Accept" => "application/json" } }
1813

1914
before do
2015
ActiveResource::HttpMock.respond_to do |mock|

spec/features/fill_in_autocomplete_question_spec.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,8 @@
88
let(:answer_text) { "Answer 1" }
99
let(:reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase }
1010

11-
let(:req_headers) do
12-
{
13-
"X-API-Token" => Settings.forms_api.auth_key,
14-
"Accept" => "application/json",
15-
}
16-
end
17-
18-
let(:post_headers) do
19-
{
20-
"X-API-Token" => Settings.forms_api.auth_key,
21-
"Content-Type" => "application/json",
22-
}
23-
end
11+
let(:req_headers) { { "Accept" => "application/json" } }
12+
let(:post_headers) { { "Content-Type" => "application/json" } }
2413

2514
before do
2615
ActiveResource::HttpMock.respond_to do |mock|

spec/features/fill_in_file_upload_question_spec.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,8 @@
99
let(:answer_text) { "Answer 1" }
1010
let(:reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase }
1111

12-
let(:req_headers) do
13-
{
14-
"X-API-Token" => Settings.forms_api.auth_key,
15-
"Accept" => "application/json",
16-
}
17-
end
18-
19-
let(:post_headers) do
20-
{
21-
"X-API-Token" => Settings.forms_api.auth_key,
22-
"Content-Type" => "application/json",
23-
}
24-
end
12+
let(:req_headers) { { "Accept" => "application/json" } }
13+
let(:post_headers) { { "Content-Type" => "application/json" } }
2514

2615
let(:test_file) { "tmp/a-file.txt" }
2716
let(:test_file_content) { "some content" }

spec/features/fill_in_form_with_exit_page_spec.rb

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,8 @@
77
let(:question_text) { Faker::Lorem.question }
88
let(:reference) { Faker::Alphanumeric.alphanumeric(number: 8).upcase }
99

10-
let(:req_headers) do
11-
{
12-
"X-API-Token" => Settings.forms_api.auth_key,
13-
"Accept" => "application/json",
14-
}
15-
end
16-
17-
let(:post_headers) do
18-
{
19-
"X-API-Token" => Settings.forms_api.auth_key,
20-
"Content-Type" => "application/json",
21-
}
22-
end
10+
let(:req_headers) { { "Accept" => "application/json" } }
11+
let(:post_headers) { { "Content-Type" => "application/json" } }
2312

2413
before do
2514
ActiveResource::HttpMock.respond_to do |mock|

0 commit comments

Comments
 (0)