Skip to content

dolphin-maps: MusicKit key container (dolphin-maps/musickit), loaded into prod and stage Workers - #715

Merged
ejc3 merged 3 commits into
mainfrom
dolphin-maps-musickit
Oct 28, 2026
Merged

ejc3 merged 3 commits into
mainfrom
dolphin-maps-musickit

Conversation

@ejc3

@ejc3 ejc3 commented Oct 27, 2026 •

Copy link
Copy Markdown
Owner

dolphin-labs-hq/dolphin-maps is adding Apple Music (its docs/design/music.md, stage 7). The car screen plays it through MusicKit JS, which needs a developer token: an ES256 JWT signed with a MusicKit private key. The site's Worker mints short-lived ones at /api/music/apple/token, so the Worker needs the key. This PR adds a place to keep it and loads it into both Workers.

What changes

  • dolphin-maps-musickit.tf: a Secrets Manager container, dolphin-maps/musickit (us-west-1). Its JSON holds MUSICKIT_KEY_ID, MUSICKIT_TEAM_ID and MUSICKIT_PRIVATE_KEY (the PEM text of the .p8 file).
    • A resource policy denies GetSecretValue to anyone outside games_mp_admin_principals.
    • dev-server-role gets PutSecretValue and DescribeSecret on this one secret, and no GetSecretValue, as a statement in the existing dev-dolphin-maps-pems policy (the role is at IAM's 20 managed-policy attachments). The key was made from a dev box's session, so the box can store it but never read it back.
    • Terraform never holds the value.
  • scripts/workers-prod-secrets.sh and scripts/workers-stage-secrets.sh: for dolphin-maps, the loader also reads this container and merges its three names.
    • It reads with the caller's own credentials. This container lives in this account, unlike the site's other containers, which are in the Dolphin account.
    • If the container has no value yet (ResourceNotFoundException), the loader says so and loads without it. The site then keeps Apple Music off on the car screen.
    • These refuse the whole load before Wrangler runs: any other read failure, a set of names that isn't exactly those three, a key id or team id that isn't 10 characters, a key that isn't PEM, and a name that is also in another container.
  • Tests: scripts/test-dolphin-maps-prod.py and scripts/test-workers-stage-secrets.py.
    • The fake aws now answers for the container.
    • New tests cover these cases: the key is merged; it is read with the caller's credentials; there is no value yet; the read is denied; the container is malformed; a name collides; no other site reads it; values are never printed.
    • The new tests were seen failing against the old scripts (9 and 2 failures) and passing with the change.
  • AGENTS.md: an entry next to the PeMS login.

One key for prod and stage. The owner chose this. A developer token identifies the app to Apple, not a person, and carries no one's data. To rotate it, make a second MusicKit key for the same Media ID (Apple allows two), put it here, load it, then revoke the first.

After this is applied

  1. A dev box puts the value with the jq … | aws secretsmanager put-secret-value … file:///dev/stdin command in the .tf header.
  2. After the site's next deploy, run scripts/workers-stage-secrets.sh dolphin-maps and scripts/workers-prod-secrets.sh dolphin-maps.

Tests run: python3 scripts/test-dolphin-maps-prod.py (24 OK), python3 scripts/test-workers-stage-secrets.py (22 OK), and every other scripts/test-*.py. Two of those need root or a Terraform init and fail the same way on main. terraform fmt -check passes.

- dolphin-maps-musickit.tf: the Secrets Manager container dolphin-maps/musickit
  (JSON: MUSICKIT_KEY_ID, MUSICKIT_TEAM_ID, MUSICKIT_PRIVATE_KEY), readable by
  administration only; dev-server-role may put and describe it, never read it.
  No value in Terraform.
- scripts/workers-prod-secrets.sh and workers-stage-secrets.sh: for dolphin-maps,
  read it with the caller's own credentials (this account) and merge its three
  names into dolphin-maps-prod / -stage. No value yet: load without it. Any other
  read failure, a wrong set of names, a non-PEM key or a name in two containers
  refuses the load before Wrangler runs.
- Tests for both loaders (fake aws gains the container); AGENTS.md entry.
@coderabbitai

coderabbitai Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 658f3fc3-a050-4a32-bbcc-b3ac06250151
Commits

Reviewing files that changed from the base of the PR and between e4e019d and ab29e0c.

Files selected for processing: 8
  • AGENTS.md
  • dolphin-maps-loop.tf
  • dolphin-maps-musickit.tf
  • scripts/test-dolphin-maps-loop.py
  • scripts/test-dolphin-maps-prod.py
  • scripts/test-workers-stage-secrets.py
  • scripts/workers-prod-secrets.sh
  • scripts/workers-stage-secrets.sh
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-28T06:28:23.167999Z ab29e0c Manual request
🔒 Security Review ✅ Completed 2026-10-28T06:30:39.976504Z ab29e0c Manual request
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 13fb6bf417

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread dolphin-maps-musickit.tf Outdated
dev-server-role is at IAM's 20 managed-policy attachments (Codex on #715): the
PutSecretValue/DescribeSecret statement on dolphin-maps/musickit moves into
dev-dolphin-maps-pems's document instead of a policy and attachment of its own.
The policy's description is unchanged (a change would replace it).

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex security review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: b7acb572f8

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@codex security review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@coderabbitai review

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

@greptileai review

@coderabbitai

coderabbitai Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: ab29e0c890

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@chatgpt-codex-connector

Copy link
Copy Markdown

🛡️ Codex Security Review

Security review completed. No security issues were found in this pull request.

Reviewed commit: ab29e0c890

View security finding report

Only the user who started this review can view the report in Codex.

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review

Once complete, Codex will leave suggestions, or a comment if no findings are found.

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Ready at ab29e0c. Two independent HIGH code/security reviews pass, all 63 focused ARM tests pass, both required CI workflows are green, and exact-head Codex code/security reviews are clean. The prior managed-policy-attachment P1 is resolved by reusing the existing PeMS policy; the corrected per-SID regression verifies MusicKit write-only access and rejects a read grant. No unresolved review threads. CodeRabbit is quota-limited and Greptile did not respond; neither is counted as approval.

Read-only live metadata confirms the MusicKit container is absent. Terraform can safely create it empty and never holds its payload. Out-of-band population and Worker loads require the correct existing MusicKit app key, which is being verified separately; no unverified key will be used. Private key material remains outside Terraform, output, and Git.

@ejc3
ejc3 merged commit f838f81 into main Oct 28, 2026
3 checks passed

ejc3 commented Oct 28, 2026

Copy link
Copy Markdown
Owner Author

Applied at merged main 156cf71. The reviewed full plan applied successfully (2 added, 6 changed, 0 destroyed), and the full 2,526-resource follow-up returned exit 0 / no changes. /infra/applied-status is published clean for this commit.

Post-apply verification passed: the MusicKit container exists with zero secret versions, its read-deny policy matches the reviewed administration boundary, the shared PeMS policy has exactly the three scoped statements, and dev-server-role remains at 20 attachments. Simulations allow only the intended MusicKit Put/Describe grant; an actual read attempt from the running ARM dev role returned AccessDenied.

Runtime bootstrap remains pending the correct MusicKit app key. Neither Worker currently has MusicKit bindings. A key file found on the Mac could not be verified as MusicKit, so it was not read or used; no payload was stored and neither Worker loader was run. Apple Music activation is not claimed. The owner has been asked for the machine/path of the correct .p8 key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant