Skip to content

fix(accounts): order an API key's variables from where to how - #619

Merged
alukach merged 1 commit into
mainfrom
feat/api-key-env-order
Oct 2, 2026
Merged

alukach merged 1 commit into
mainfrom
feat/api-key-env-order

Conversation

@alukach

@alukach alukach commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

What

An API key's Example usage now lists its variables from where requests go to how they sign in:

export AWS_REGION=us-west-2
export AWS_ENDPOINT_URL_S3=https://data.source.coop
export AWS_ENDPOINT_URL_STS=https://data.source.coop/.sts
export AWS_ROLE_ARN=arn:aws:iam::your-org--nightly-sync:role/FullAccess
export AWS_WEB_IDENTITY_TOKEN_FILE=/path/to/the/saved/key

It used to start with the role and key file and end with the region. Only the order changes; every value is the same. apiKeyEnvironment is the one place it's built, so the key row's dialog and the story both follow.

Story: ExampleUsage / ApiKey. The snippet above is the whole visual change, so there's no screenshot.

Testing

  • service-account-usage.test.ts now pins the whole snippet with toBe, where it used to check three lines with toContain, so the order is tested. It passes.
  • npm run type-check passes.

Docs and ADRs

source-cooperative/docs.source.coop#37 documents this snippet on its Automated Access page and now uses the same order. No ADR covers the order.

🤖 Generated with Claude Code

https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp

The example for an API key now reads region, S3 endpoint, STS endpoint, role, then key file: where requests go before how they sign in. The test pins the whole snippet, so the order is checked rather than only its lines.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp
@vercel

vercel Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
source-coop-ui Ready Ready Preview Oct 2, 2026 3:54am UTC
source-cooperative Ready Ready Preview Oct 2, 2026 3:54am UTC

Request Review

@claude

claude Bot commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Claude finished @alukach's task in 8s —— View job


✅ No blocking issues — safe to merge.

The diff only reorders the lines in apiKeyEnvironment (src/lib/services/service-account-usage.ts). Every value is unchanged. The test now pins the whole snippet with toBe, so the order is covered.

Docs

The PR description names source-cooperative/docs.source.coop#37, which documents this snippet and uses the same order. It also says no ADR covers the order. That satisfies the CLAUDE.md requirement. I didn't open docs.source.coop#37 to check it.


💰 Estimated review cost: $0.10 · 0m08s · 4 turns

alukach added a commit to source-cooperative/docs.source.coop that referenced this pull request Oct 2, 2026
The example now matches the order source.coop prints (source-cooperative/source.coop#619): region, S3 endpoint, STS endpoint, role, key file. The table below it follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp
@alukach
alukach marked this pull request as ready for review October 2, 2026 04:34
@alukach
alukach merged commit 93c800c into main Oct 2, 2026
11 checks passed
@alukach
alukach deleted the feat/api-key-env-order branch October 2, 2026 04:34
alukach added a commit to source-cooperative/docs.source.coop that referenced this pull request Oct 6, 2026
…de (#37)

* docs: add an automated access guide for service accounts

Adds Automated Access (docs/using-source/automated-access.md), the guide for software that reaches Source Cooperative with nobody at the keyboard: what a service account is; creating one and granting it products; issuing an API key and the five variables the AWS CLI or an SDK needs to exchange it at the data proxy; the refusal users see and the request id to quote; keeping the key out of URLs and debug output; rotation and editable expiry; tools that keep their first credentials; GDAL; revocation, the emergency stop and revoking a found key; and GitHub Actions as coming soon. The page is added to sidebars.ts.

Upload Your Data's Option 3 walked through trusting an IAM role in the uploader's own AWS account to write straight to Source's bucket. Service accounts supersede it, so the section is now a pointer to the new page, as are the two references to it earlier on that page and the "contact us" line for automated access. Access Data gains one sentence pointing unattended software at service accounts.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1eiTse4416N6uTgAy4Ddd

* docs: say what the malformed-key error means

An API key now ends in a six-character checksum of the rest (ADR-013, source-cooperative/data.source.coop#242), so the data proxy and the Source CLI refuse a key that was cut short or mistyped before anything is looked up, with "API key is malformed; check that it was copied whole". The guide's "If the key is refused" section shows that error and what to do about it, and no longer says a value that isn't a key gets "API key was not accepted".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01R1eiTse4416N6uTgAy4Ddd

* docs: document GitHub Actions sign-in, ReadOnly, and the current service account UI

GitHub Actions trust shipped in data.source.coop#237 (which implements #222 and #223), so the "coming soon" note becomes instructions: trusting a workflow, the step from Example usage, why a job with an environment or a pull_request trigger carries a different subject, role-duration-seconds for long jobs, and the AccessDenied a refused sign-in gets. The API-key section now says how to choose ReadOnly, and that any other role name is refused. The create and issue steps follow the UI on source.coop main: sign-ins are added under "How software signs in" at creation or from "Add sign-in" under "Signs in with", and the variables, Change expiry and Revoke live in each row's menu. The stop table gains removing a workflow, and disabling now names workflow sign-ins too (authenticateWithOidcToken refuses a disabled account).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp

* docs: list an API key's variables from where to how

The example now matches the order source.coop prints (source-cooperative/source.coop#619): region, S3 endpoint, STS endpoint, role, key file. The table below it follows.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp

* docs: split Upload Your Data into browser, CLI and service account pages

Upload Your Data becomes a sidebar category. Its index keeps /data-upload with what every method shares (how the proxy works, where to upload, the controls) and a table for choosing a method. Option 1 becomes Upload in the Browser (/upload-in-the-browser), Option 2 becomes Upload with the Source CLI (/upload-with-the-cli) with View Credentials as its no-CLI fallback, and Automated Access moves in as With a Service Account, keeping /automated-access. The index carries HTML anchors for the old Option headings and the CLI heading Access Data linked to, so existing links still land. Content moves unchanged apart from headings and a sentence of glue per page.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp

* docs: explain AWS_REGION, and drop the note that proxy uploads are disabled

The data proxy verifies signatures with whatever region the client signed for and uses it for nothing else, but many SDKs refuse to sign without one, so both credential pages now say to set it anyway. Access Data's closing section said uploading through the proxy was disabled, which the Upload Your Data pages contradict; it is gone.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014rVE6YPLaG5BrUoC76r3fp

* docs: note that only owners and maintainers manage service accounts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: keep the IAM-role upload instructions at /direct-uploads, marked deprecated

Pipelines that write straight to the bucket with their own IAM role still
need these instructions until they move to service accounts. The page stays
out of the sidebar; the upload index links to it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* tools: mark the IAM policy wizard deprecated and link it to /direct-uploads

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: drop the upload index's advice against permanent keys

Service account API keys can be issued without an expiry, so the index
shouldn't forbid them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: set AWS_DEFAULT_REGION, which boto3 reads, instead of AWS_REGION

botocore reads only AWS_DEFAULT_REGION, so with AWS_REGION alone boto3 had
no region. Note that the JavaScript and Java SDKs read AWS_REGION.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: give the key file as a full path, not $HOME

Cron and systemd, where the page tells readers to copy these variables,
do not expand $HOME, so the job would look for a literal "$HOME/..." path.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: keep a found key off the command line when revoking it

The example put the key in curl's arguments, where it lands in shell
history and is visible in ps, against the page's own advice.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: create the key file private from the start

mkdir -m leaves an existing directory's mode alone, and the key file was
readable by others between cat and chmod. chmod the directory, and create
the file under umask 077 in a subshell so the shell's umask is untouched.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: clarify how software signs in, name the Grant button, keep old anchors

- Explain in the intro that a service account signs in with a GitHub
  workflow token or an API key, and what 'nothing else has to run' meant.
- The grant dialog's button is labelled Grant, not a check mark.
- Keep the old page's sub-section anchors so links into it land beside the
  page that now covers them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: keep AWS_REGION, and note that boto3 needs AWS_DEFAULT_REGION

AWS_REGION is what most SDKs and the app's example usage read; boto3 is
the one that reads only AWS_DEFAULT_REGION.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: drop the files/folders/objects list from the upload index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: drop the 'Why we use these controls' section from the upload index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: drop the 'What not to do' section from the upload index

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* docs: list Direct Uploads (Deprecated) in the sidebar

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* Simplify

* Prefer account rather than org

* Add windows focused examples

* Rename file

* Reorganize, format

* Simplify

* line-wrap plain-text code blocks

* Add more windows friendly docs

* Prefer account-id / product-id

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>

This branch was successfully deployed

2 active deployments
Preview – source-cooperative — 27418e36 Deployed Oct 2, 2026 by vercel[bot]
Preview – source-coop-ui — 27418e36 Deployed Oct 2, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant