Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Rails application secret and change to env secret #2426

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/controllers/link_checker_api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,6 @@ def verify_signature
end

def webhook_secret_token
Rails.application.secrets.link_checker_api_secret_token
ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN")
end
end
2 changes: 1 addition & 1 deletion app/services/link_check_report_creator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def call_link_checker_api
GdsApi.link_checker_api.create_batch(
uris,
webhook_uri: callback_url,
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN"),
)
end

Expand Down
2 changes: 1 addition & 1 deletion config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class Application < Rails::Application
config.asset_host = ENV.fetch("ASSET_HOST", nil)

config.action_mailer.notify_settings = {
api_key: Rails.application.secrets.notify_api_key || "fake-test-api-key",
api_key: ENV.fetch("GOVUK_NOTIFY_API_KEY", "fake-test-api-key"),
}

config.generators do |g|
Expand Down
26 changes: 0 additions & 26 deletions config/secrets.yml

This file was deleted.

2 changes: 1 addition & 1 deletion test/functional/link_check_reports_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class LinkCheckReportsControllerTest < ActionController::TestCase
uris: ["https://www.gov.uk"],
id: 1234,
webhook_uri: link_checker_api_callback_url(host: Plek.find("publisher")),
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV["LINK_CHECKER_API_SECRET_TOKEN"],
)
end

Expand Down
2 changes: 1 addition & 1 deletion test/functional/link_checker_api_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def campaign_edition_link_check_report
def set_headers(post_body)
headers = {
"Content-Type": "application/json",
"X-LinkCheckerApi-Signature": generate_signature(post_body.to_json, Rails.application.secrets.link_checker_api_secret_token),
"X-LinkCheckerApi-Signature": generate_signature(post_body.to_json, ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN")),
}

request.headers.merge! headers
Expand Down
2 changes: 1 addition & 1 deletion test/integration/edition_link_check_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class EditionLinkCheckTest < LegacyJavascriptIntegrationTest
uris: ["https://www.gov.uk"],
id: 1234,
webhook_uri: link_checker_api_callback_url(host: Plek.find("publisher")),
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN"),
)

@place = FactoryBot.create(:place_edition, introduction: "This is [link](https://www.gov.uk) text.")
Expand Down
2 changes: 1 addition & 1 deletion test/unit/services/link_check_report_creator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def create_edition(govspeak)
uris: ["https://www.gov.uk"],
id: 1234,
webhook_uri: link_checker_api_callback_url(host: Plek.find("publisher")),
webhook_secret_token: Rails.application.secrets.link_checker_api_secret_token,
webhook_secret_token: ENV.fetch("LINK_CHECKER_API_SECRET_TOKEN"),
)
end

Expand Down
Loading