Skip to content

Commit 259c624

Browse files
authored
Deliver FIZZY_REVIEWER_SIGN_IN_CODES to production (#3282)
Deliver FIZZY_REVIEWER_SIGN_IN_CODES to production #3257 moved directory reviewers to one code per partner, read from FIZZY_REVIEWER_SIGN_IN_CODES, and left wiring that secret into the production deploy for later. Production still fetches and sets only the single FIZZY_REVIEWER_SIGN_IN_EMAIL / FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST pair, so the per-partner list is always nil there. Fetch it, extract it and pass it to the containers beside the pair. The pair stays: Identity::ReviewerSignIn still reads it beside the list. A test now checks production's three secret lists agree (every env.secret name is assigned, every extracted name is fetched) and that the reviewer sign-in variables are among them.
1 parent 381a1d3 commit 259c624

3 files changed

Lines changed: 56 additions & 1 deletion

File tree

‎saas/.kamal/secrets.production‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SECRETS=$(kamal secrets fetch --adapter 1password --account 23QPQDKZC5BKBIIG7UGT5GR5RM --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Deployments/DASH_BASIC_AUTH_SECRET Production/RAILS_MASTER_KEY Production/MYSQL_ALTER_PASSWORD Production/MYSQL_ALTER_USER Production/MYSQL_APP_PASSWORD Production/MYSQL_APP_USER Production/MYSQL_READONLY_PASSWORD Production/MYSQL_READONLY_USER Production/SECRET_KEY_BASE Production/VAPID_PUBLIC_KEY Production/VAPID_PRIVATE_KEY Production/ACTIVE_STORAGE_ACCESS_KEY_ID Production/ACTIVE_STORAGE_SECRET_ACCESS_KEY Production/ACTIVE_STORAGE_DIRECT_UPLOAD_ACCESS_KEY_ID Production/ACTIVE_STORAGE_DIRECT_UPLOAD_SECRET_ACCESS_KEY Production/QUEENBEE_API_TOKEN Production/QUEENBEE_API_TOKEN_PREVIOUS Common/queenbee_secret Production/SIGNAL_ID_SECRET Production/SENTRY_DSN Production/ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY Production/ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY Production/ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT Production/STRIPE_MONTHLY_V1_PRICE_ID Production/STRIPE_MONTHLY_EXTRA_STORAGE_V1_PRICE_ID Production/STRIPE_SECRET_KEY Production/STRIPE_WEBHOOK_SECRET Production/APNS_KEY_ID Production/APNS_ENCRYPTION_KEY_B64 Production/FCM_ENCRYPTION_KEY_B64 Production/FIZZY_REVIEWER_SIGN_IN_EMAIL Production/FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST Production/OAUTH_TOKEN_PEPPER Production/FIZZY_MCP_EXCHANGE_CLIENT_SECRET Production/CONNECTED_APPS_PREVIEW_REVIEWERS)
1+
SECRETS=$(kamal secrets fetch --adapter 1password --account 23QPQDKZC5BKBIIG7UGT5GR5RM --from Deploy/Fizzy Deployments/BASECAMP_REGISTRY_PASSWORD Deployments/DASH_BASIC_AUTH_SECRET Production/RAILS_MASTER_KEY Production/MYSQL_ALTER_PASSWORD Production/MYSQL_ALTER_USER Production/MYSQL_APP_PASSWORD Production/MYSQL_APP_USER Production/MYSQL_READONLY_PASSWORD Production/MYSQL_READONLY_USER Production/SECRET_KEY_BASE Production/VAPID_PUBLIC_KEY Production/VAPID_PRIVATE_KEY Production/ACTIVE_STORAGE_ACCESS_KEY_ID Production/ACTIVE_STORAGE_SECRET_ACCESS_KEY Production/ACTIVE_STORAGE_DIRECT_UPLOAD_ACCESS_KEY_ID Production/ACTIVE_STORAGE_DIRECT_UPLOAD_SECRET_ACCESS_KEY Production/QUEENBEE_API_TOKEN Production/QUEENBEE_API_TOKEN_PREVIOUS Common/queenbee_secret Production/SIGNAL_ID_SECRET Production/SENTRY_DSN Production/ACTIVE_RECORD_ENCRYPTION_PRIMARY_KEY Production/ACTIVE_RECORD_ENCRYPTION_DETERMINISTIC_KEY Production/ACTIVE_RECORD_ENCRYPTION_KEY_DERIVATION_SALT Production/STRIPE_MONTHLY_V1_PRICE_ID Production/STRIPE_MONTHLY_EXTRA_STORAGE_V1_PRICE_ID Production/STRIPE_SECRET_KEY Production/STRIPE_WEBHOOK_SECRET Production/APNS_KEY_ID Production/APNS_ENCRYPTION_KEY_B64 Production/FCM_ENCRYPTION_KEY_B64 Production/FIZZY_REVIEWER_SIGN_IN_EMAIL Production/FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST Production/FIZZY_REVIEWER_SIGN_IN_CODES Production/OAUTH_TOKEN_PEPPER Production/FIZZY_MCP_EXCHANGE_CLIENT_SECRET Production/CONNECTED_APPS_PREVIEW_REVIEWERS)
22

33
GITHUB_TOKEN=$(gh config get -h github.com oauth_token)
44
BASECAMP_REGISTRY_PASSWORD=$(kamal secrets extract BASECAMP_REGISTRY_PASSWORD $SECRETS)
@@ -35,5 +35,6 @@ APNS_ENCRYPTION_KEY_B64=$(kamal secrets extract APNS_ENCRYPTION_KEY_B64 $SECRETS
3535
FCM_ENCRYPTION_KEY_B64=$(kamal secrets extract FCM_ENCRYPTION_KEY_B64 $SECRETS)
3636
FIZZY_REVIEWER_SIGN_IN_EMAIL=$(kamal secrets extract FIZZY_REVIEWER_SIGN_IN_EMAIL $SECRETS)
3737
FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST=$(kamal secrets extract FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST $SECRETS)
38+
FIZZY_REVIEWER_SIGN_IN_CODES=$(kamal secrets extract FIZZY_REVIEWER_SIGN_IN_CODES $SECRETS)
3839
FIZZY_MCP_EXCHANGE_CLIENT_SECRET=$(kamal secrets extract FIZZY_MCP_EXCHANGE_CLIENT_SECRET $SECRETS)
3940
CONNECTED_APPS_PREVIEW_REVIEWERS=$(kamal secrets extract CONNECTED_APPS_PREVIEW_REVIEWERS $SECRETS)

‎saas/config/deploy.production.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ env:
7676
# Directory reviewer sign-in (Identity::ReviewerSignIn). The email is a secret only to keep it out of this public repo.
7777
- FIZZY_REVIEWER_SIGN_IN_EMAIL
7878
- FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST
79+
- FIZZY_REVIEWER_SIGN_IN_CODES
7980
# Identity ids of the connected apps preview's reviewers (Oauth::Availability).
8081
- CONNECTED_APPS_PREVIEW_REVIEWERS
8182
tags:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
require "test_helper"
2+
require "erb"
3+
require "kamal"
4+
5+
# Production's secrets reach a container through three lists that nothing else keeps in step:
6+
# the env.secret names in deploy.production.yml, the assignments in .kamal/secrets.production,
7+
# and the names that file's one `kamal secrets fetch` asks for. A name missing from the first
8+
# leaves the app reading nil; one missing from either of the others fails the deploy.
9+
class ProductionSecretsTest < ActiveSupport::TestCase
10+
SECRETS_FILE = Rails.root.join("saas/.kamal/secrets.production")
11+
12+
test "production delivers every variable reviewer sign-in reads" do
13+
%w[ FIZZY_REVIEWER_SIGN_IN_EMAIL FIZZY_REVIEWER_SIGN_IN_CODE_DIGEST FIZZY_REVIEWER_SIGN_IN_CODES ].each do |name|
14+
assert_includes web_secret_keys, name
15+
end
16+
end
17+
18+
test "every secret production's containers read is assigned, and every extracted one is fetched" do
19+
secret_keys.each do |key|
20+
assert assignments.key?(key), "#{key} isn't assigned in #{SECRETS_FILE.basename}"
21+
22+
if extracted = assignments[key][/\A\$\(kamal secrets extract (\S+) \$SECRETS\)\z/, 1]
23+
assert_includes fetched, extracted, "#{key} is extracted but not fetched"
24+
end
25+
end
26+
end
27+
28+
private
29+
def web_secret_keys
30+
configuration.role(:web).env(configuration.role(:web).hosts.first).secret_keys
31+
end
32+
33+
def secret_keys
34+
roles = configuration.roles.flat_map { |role| role.env(role.hosts.first).secret_keys }
35+
accessories = configuration.accessories.flat_map { |accessory| accessory.env.secret_keys }
36+
37+
(roles + accessories).map { it.split(":", 2).last }.uniq
38+
end
39+
40+
def assignments
41+
@assignments ||= SECRETS_FILE.readlines(chomp: true).filter_map { it.match(/\A(\w+)=(.*)\z/)&.captures }.to_h
42+
end
43+
44+
# The fetched names, without the section each is read from.
45+
def fetched
46+
assignments.fetch("SECRETS").split(" --from ").last.split.drop(1).map { it.split("/").last.delete_suffix(")") }
47+
end
48+
49+
def configuration
50+
@configuration ||= Kamal::Configuration.create_from(
51+
config_file: Rails.root.join("saas/config/deploy.yml"), destination: "production", version: "test")
52+
end
53+
end

0 commit comments

Comments
 (0)