Performance insights, Goals & Events, 2FA improvements, auth fixes #36
Reference in New Issue
Block a user
No description provided.
Delete Branch "staging"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Work Item
Summary
Changes
Added
pulse.track()in snippet; goal counts on dashboard..txtfile; regeneration invalidates existing codes.Fixed
Test Plan
pulse.track()from snippet; confirm goal counts on dashboard..txtdownload; verify old codes are invalid.Greptile Summary
This PR delivers several improvements: automatic token refresh to fix frequent re-login issues, middleware fix for post-inactivity sign-in, password-confirmed 2FA disable/recovery code regeneration, WebAuthn/passkey support wiring, and changelog/dependency updates.
AuthProvidernow attempts a token refresh when the access token is expired but a refresh token exists, fixing the 15-minute inactivity logout. Thefetchcall should be wrapped in try/catch to prevent unhandled errors from leaving the app in a permanent loading state.access_tokeninstead of any session cookie, preventing stale refresh tokens from blocking login.disable2FAandregenerateRecoveryCodesnow require a derived password, preventing session-hijacking attacks from stripping 2FA.lib/api/webauthn.tswith clean register/list/delete passkey operations wired intoProfileSettings.Confidence Score: 2/5
app/auth/callback/page.tsx(CSRF risk from skipped state validation) andlib/auth/context.tsx(unhandled fetch error in refresh logic).Important Files Changed
Sequence Diagram
Last reviewed commit:
2cb8ffd10 files reviewed, 3 comments
Edit Code Review Agent Settings | Greptile
Empty
code_verifierdisables PKCE protectionWhen
codeVerifierisnull(session-authorized flow), this sendscode_verifier: ''to the token endpoint. For PKCE to provide any security, the auth server must reject token requests with an empty verifier when the authorization request included acode_challenge. If the auth server does not enforce this (i.e., it accepts empty verifiers), then PKCE is effectively optional, and authorization code interception attacks become possible for the auth-hub flow.Please verify that the auth server either:
code_verifierwhen acode_challengewas provided during authorization, orIf the auth server silently accepts the empty verifier, this is a security gap.
Prompt To Fix With AI
Skipping state validation opens a CSRF vector
When
storedStateorcodeVerifierare absent (the "session-authorized flow"), both the OAuthstatecheck and PKCE verification are bypassed entirely. This makes the callback vulnerable to login CSRF: an attacker can craft a link like/auth/callback?code=ATTACKER_CODEand trick a victim into visiting it, logging the victim into the attacker's account (a classic OAuth login CSRF attack).The
stateparameter exists specifically to prevent this. Even for the auth-hub-initiated flow, the hub should be able to pass astatevalue that Pulse can verify (e.g., a server-side nonce or a signed token), or Pulse should generate and store its ownstatebefore redirecting to the hub.Consider one of these mitigations:
stateparameter that Pulse can validate (e.g. a signed value from the hub).statenonce on Pulse's side before the hub redirect, then validate it in this callback.stateis present, verify thecodewas issued very recently (short TTL) and for the correctredirect_urion the server side, and document the accepted risk.Prompt To Fix With AI
@@ -115,1 +124,4 @@}}if (session) {Silent refresh failure may hide errors
When the refresh request fails (non-ok response or network error), the code silently falls through to the
elsebranch which setsusertonull. This is functionally correct, but afetchexception (e.g., network failure) will propagate as an unhandled error from theinitfunction, which could cause theloadingstate to never be set tofalse, leaving the app in a permanent loading state.Consider wrapping the refresh attempt in a try/catch:
Prompt To Fix With AI