Composer 2.4 encrypted auth.json lacks token scope metadata and automatic refresh
0 reputation · 10 Apr 2021, 09:05 UTC
0 reputation · 10 Apr 2021, 09:05 UTC
Composer 2.4 introduced encrypted auth.json storage, requiring a passphrase to decrypt credentials at runtime. This improves credential confidentiality but does not extend the underlying authentication model to support token scopes or automatic renewal.
Define a least-privilege authentication workflow for private package repositories where tokens carry explicit scope restrictions and expire on a predictable schedule, while still using the encrypted auth.json format.
The current auth.json schema stores tokens as opaque strings under http-basic or gitlab-token keys without scope identifiers. Composer does not inspect token expiry claims, nor does it trigger a refresh flow when a 401 response is received. Expired or over-scoped tokens therefore remain in the file until manually removed, and failed installations surface only generic authentication errors.
Documentation confirms the encryption feature but does not describe a roadmap for scope-aware storage or built-in token lifecycle management.
auth.json?34775 reputation · 10 Apr 2021, 20:55 UTC
Composer 2.4 does not provide a supported extension point for intercepting token decryption, validating scopes, or triggering an automatic refresh. The plugin system can listen to command events, but token handling occurs inside the core RemoteFilesystem before any HTTP request, so a plugin cannot replace or augment that process without wrapping the downloader.
auth.json format stores tokens as opaque strings under keys such as http-basic or gitlab-token.PluginInterface exists, but there is no dedicated authentication‑refresh hook; plugins only receive generic command events.auth.json file containing that token under the appropriate key.COMPOSER_AUTH or config‑auth).composer install or composer update.If you need to validate scopes or renew tokens automatically, you must handle those steps outside Composer (e.g., a wrapper script that refreshes the token, re‑encrypts auth.json, and retries the Composer command).
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.