Commit 677ac41
fix(auth): encrypt OAuth tokens using encryption utility directly (#144)
* fix(auth): encrypt OAuth tokens using encryption utility directly
auth.ts silently stored GitHub OAuth access tokens as plaintext because
the encryption check relied on a non-existent `app.encryption` Fastify
decorator - the condition always evaluated false, falling back to the raw
token. connect.ts called `app.encryption.encrypt()` directly, throwing
a TypeError at runtime and breaking the GitHub connect flow entirely.
Both routes now import `encrypt()` directly from utils/encryption.ts,
consistent with how follow.ts already imports `decrypt()` from the same module.
* fix(auth): isolate OAuth token persistence with focused try/catch
Wrap the encrypt + oAuthToken.upsert block in its own try/catch so that
a transient DB failure during token storage does not abort the login flow.
The platform token is supplementary -- authentication (JWT issuance) proceeds
even when persistence fails, and the error is logged for observability.
Addresses reviewer feedback on PR #144.
---------
Signed-off-by: Prashantkumar Khatri <96608160+ShantKhatri@users.noreply.github.com>
Co-authored-by: Prashantkumar Khatri <96608160+ShantKhatri@users.noreply.github.com>1 parent 0b03d68 commit 677ac41
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
3 | 4 | | |
4 | 5 | | |
5 | 6 | | |
| |||
119 | 120 | | |
120 | 121 | | |
121 | 122 | | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
122 | 136 | | |
123 | 137 | | |
124 | 138 | | |
| |||
0 commit comments