sec(oauth): cifra o oauth-store em repouso (AES-256-GCM)#153
Merged
Conversation
data/oauth-store.json guardava client secrets + access/refresh tokens em TEXTO
CLARO no disco. Passa a cifrar com a mesma chave do vault (encryptSecret), em
módulo puro separado (oauth-store-codec) — oauth.ts faz process.exit no import,
então o codec fica testável sozinho.
- saveStore cifra o JSON (envelope v1:...); loadStore decifra.
- Backward-compatible: um store legado em claro (começa com '{') carrega como
está e é re-cifrado no próximo save. Sem passo manual de migração.
- Fail-safe: sem SECRETS_KEY o encode cai pra texto puro + warning (nunca quebra
a persistência); loadStore separa "arquivo ausente" (silencioso) de "existe mas
não decodifica" (erro ALTO) pra não apagar tokens em silêncio num mismatch de chave.
SECRETS_KEY confirmada presente na VPS. build+test verdes (1352/1352, 3 testes novos).
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Cifra o oauth-store em repouso
data/oauth-store.jsonguardava client secrets + access/refresh tokens em texto claro no disco. Agora é cifrado com a chave do vault (encryptSecret, AES-256-GCM viaSECRETS_KEY).oauth-store-codec.ts) —oauth.tsfazprocess.exitno import, então o codec fica testável sozinho (3 testes: round-trip, passthrough de legado, fallback sem chave).saveStorecifra (envelopev1:...);loadStoredecifra.{) carrega como está e é re-cifrado no próximo save. Sem passo manual.SECRETS_KEYo encode cai pra texto puro + warning (nunca quebra persistência);loadStoresepara "arquivo ausente" (silencioso) de "existe mas não decodifica" (erro ALTO) pra um mismatch de chave não apagar tokens em silêncio.SECRETS_KEYconfirmada presente na VPS. No deploy vou fazer backup dooauth-store.jsonatual antes de subir.npm run build+npm testverdes (1352/1352).🤖 Generated with Claude Code