Skip to content

DO NOT MERGE: Require an organization key and store short-lived tokens#1181

Draft
ericmj wants to merge 1 commit into
mainfrom
organization-short-lived-tokens
Draft

DO NOT MERGE: Require an organization key and store short-lived tokens#1181
ericmj wants to merge 1 commit into
mainfrom
organization-short-lived-tokens

Conversation

@ericmj

@ericmj ericmj commented Jun 16, 2026

Copy link
Copy Markdown
Member

Follow-up to the deprecations in #1179 — this is the breaking change that removes the deprecated paths. It must ship in a release after the one that carries the deprecation warnings, not together with them. Draft until then.

What changes

  • mix hex.organization auth ORGANIZATION now requires --key. Without it, the task raises and points to mix hex.user auth (development) or mix hex.organization key … generate (CI).
  • mix hex.organization auth ORGANIZATION --key KEY now exchanges the key for a short-lived token immediately and stores only the token, never the key. The exchange also verifies the key grants access to the organization.
  • Organization repositories no longer authenticate with a stored API key. They use the cached short-lived token (from auth --key) or, failing that, the user's mix hex.user auth authentication. A stored auth_key left in hex.config by an older client is ignored.
  • HEX_REPOS_KEY no longer grants access to organization repositories — authenticate per organization with auth --key instead.
  • When neither a valid cached token nor user authentication is available for an organization repository, the client prints how to authenticate instead of silently failing.

Scope / compatibility

  • The base hexpm repository is unchanged, including trusted mirrors authenticated with HEX_REPOS_KEY. Full removal of HEX_REPOS_KEY is intentionally out of scope here because it is also used for mirror authentication.
  • The client_credentials exchange itself is unchanged, so CI keeps working: a job runs mix hex.organization auth ORGANIZATION --key $KEY and fetches with the resulting token. Since that exchange issues no refresh token, the token must be re-obtained after it expires (~30 min) — fine for a typical CI job, and the intended friction for a human pasting a key on a workstation.

Follow-up (separate, later)

The hexpm server should eventually reject the exchange of a user-owned key for repository scopes (returning invalid_scope), so the constraint reaches clients that are pinned to old Hex versions. That is deliberately deferred — it is a server-side breaking change to be timed against customer comms, and it is not part of this PR.

@ericmj ericmj changed the title Require an organization key and store short-lived tokens DO NOT MERGE: Require an organization key and store short-lived tokens Jun 16, 2026
mix hex.organization auth now requires --key; the key is exchanged for a
short-lived token immediately and only the token is stored, never the key.
Organization repositories no longer authenticate with a stored API key —
they use the cached short-lived token or the user's OAuth authentication —
and HEX_REPOS_KEY no longer grants access to organization repositories.

For development, mix hex.user auth grants access to all your organizations.
The base hexpm repository (including trusted mirrors authenticated with
HEX_REPOS_KEY) is unchanged.
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