Skip to content

In development. Expect rough edges and changes. The source code is not public yet.

Heroku Engineering 5 min read Release mediumAdept

Securing Heroku CLI Credentials with System Keychain Storage

Starting with version 11.8.0, the Heroku CLI stores auth tokens in the OS keychain by default instead of plaintext `.netrc` files. It uses macOS Keychain via `security`, Secret Service via `secret-tool` on Linux, and Windows PasswordVault, all under the service name "heroku-cli". Credential lookup follows a four-tier precedence: `HEROKU_API_KEY`, then `HEROKU_NETRC_WRITE=true` forcing `.netrc`, then the keychain, then `.netrc` as a fallback. A new git credential helper keeps `git push heroku main` working, and CI pipelines using `HEROKU_API_KEY` need no changes.

Assumes: command-line toolsnetrc credential files

Related posts

  • Better security for your app's secrets

    incident.io mediumAdept

    incident.io's Go app loads config from per-environment YAML files, overrides values with environment variables, then resolves `secret-manager:` references from Google Secret Manager at boot. Moving secrets out of Heroku environment variables means only a Google Service Account credential is exposed, so it can be revoked and access audited. A VPC Service Controls security perimeter with Access Levels restricts Secret Manager access to known source IPs: offices, CircleCI egress, UK/US staff locations and Heroku's AWS eu-west-1 range. The tradeoff is new availability risk, since external changes such as Heroku IP range shifts can cause outages.

  • Using GitHub Actions with Heroku Flow for additional Security Control

    Heroku Engineering mediumAdept

    Because GitHub Orgs can't allowlist Heroku IP ranges, Heroku offers a sample pattern: a self-hosted GitHub Actions runner deployed as a Docker app in a Heroku Private Space with static outbound IPs, plus a Heroku Flow Action. The action uses the Platform API's Source Endpoint to upload private repo code, deploy apps on push, dispatch or schedule events, and create, update or remove Review Apps on pull request events. A weekly scheduled workflow rebuilds and redeploys the runner to meet GitHub's 30-day update requirement. Tradeoffs include no repo link in the Review App UI, no automatic Heroku CI tests, no Fir support, and a custom runner image that other actions should be tested against.

  • Auth setup with Neon, Keycloak and Koyeb

    Neon mediumAdept

    Keycloak can use Neon serverless Postgres as its backing store, with the Keycloak server deployed as a container on Koyeb. The steps are: create a dedicated keycloak database and a scoped keycloak_admin role, then deploy Keycloak from a Koyeb template configured through KC_DB_URL, KC_DB_USERNAME, KC_DB_PASSWORD and KC_HOSTNAME. After that, import a sample realm and authenticate a Next.js app through NextAuth.js over OAuth. For production, build an optimized Keycloak image, configure connection pooling, and consider Neon branching and point-in-time restore for recovering Keycloak data.

  • Security Disclosure Recommendation: Redeploy Buckets and Reconnect GitHub After the Credential Reset

    Railway mediumAdept

    After a security disclosure, Railway invalidated and regenerated S3 access keys for every storage bucket and removed the GitHub tokens it held, including GHCR registry tokens stored on services. These resets show in the audit log under the Railway Staff actor type. Services pick up new bucket credentials only on redeploy because containers read variables at startup, so each service using a bucket needs a redeploy. Any pasted key values should be replaced with reference variables, and external tools need updating. Users must also reconnect their GitHub account and repo sources, revoke and recreate GHCR personal access tokens with read:packages, then check bucket files and audit logs for misuse during the exposure window.

  • Automatically Rotating GitHub Tokens (So You Don’t Have To)

    Shopify Engineering mediumAdept

    Shopify replaced long-lived GitHub personal access tokens with short-lived GitHub App installation tokens that are rotated automatically by scheduled GitHub Actions workflows and written into repository secrets. Developers can reference those secrets exactly as they did PATs. The design avoids breakage from developer churn and misattribution of actions, and shrinks the blast radius of leaked tokens. Lessons learned: billable minutes are rounded per job, so parallel jobs were consolidated into one sequential job. The cron `schedule` trigger is best-effort, so it moved to explicit minute-of-hour runs every 15 minutes to stay within the one-hour token expiry. Onboarding evolved into a plop.js wizard with use-case-based permission selection, and a step-by-step recipe for building the rotator closes out the write-up.

The quest for software engineering knowledge.

Look:
Layout: