Skip to content

fix(auth): auto-clear session credentials after 30 minutes of inactivity#692

Open
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/688-session-timeout
Open

fix(auth): auto-clear session credentials after 30 minutes of inactivity#692
anshul23102 wants to merge 1 commit into
GitMetricsLab:mainfrom
anshul23102:fix/688-session-timeout

Conversation

@anshul23102
Copy link
Copy Markdown
Contributor

Description

Sessions had no expiration: once a username and optional PAT were entered they remained in React state for the lifetime of the browser tab. An unattended tab with a PAT in state was exploitable for the entire browser session, and any token compromise provided indefinite access.

Root Cause

useGitHubAuth used useState for both username and token with no cleanup mechanism. No inactivity timer or session expiry was implemented.

Related Issue

Closes #688

Type of Change

  • Bug fix (security)

Changes Made

  • src/hooks/useGitHubAuth.ts: Added a 30-minute inactivity timer using useEffect and useRef. After 30 minutes without user interaction the timer calls clearSession(), zeroing both username and token. The timer resets on mousemove, keydown, click, scroll, and touchstart events. The timer is only active while a username is set and is fully cleaned up when the component unmounts or the session is cleared.

Testing Done

  1. Enter username and token: session remains active while the user interacts.
  2. Leave browser idle for 30 minutes: credentials are automatically cleared.
  3. Active interaction resets the 30-minute window each time.

Checklist

  • My code follows the style and formatting of this project
  • I have tested my changes locally and they work as expected
  • There are no merge conflicts with the base branch
  • This PR is linked to the correct issue

Sessions had no expiration: once a username and optional PAT were
entered they remained in React state indefinitely. An unattended browser
tab with a valid PAT stored in state remained exploitable for the entire
browser session.

Add an inactivity timer via useEffect. After 30 minutes without a user
interaction event (mousemove, keydown, click, scroll, touchstart) the
timer fires clearSession(), zeroing both username and token. The timer
resets on every qualifying event so active sessions are not disrupted.
When no username is set the timer is inactive and no listeners are
registered.

Closes GitMetricsLab#688
@netlify
Copy link
Copy Markdown

netlify Bot commented Jun 3, 2026

Deploy Preview for github-spy ready!

Name Link
🔨 Latest commit 210e562
🔍 Latest deploy log https://app.netlify.com/projects/github-spy/deploys/6a2027e9de3db40007a2f6c8
😎 Deploy Preview https://deploy-preview-692--github-spy.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 3, 2026

Warning

Review limit reached

@anshul23102, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 58 minutes and 51 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bc34b04d-dc3c-4b7d-aa8f-306097f87ade

📥 Commits

Reviewing files that changed from the base of the PR and between 53f820b and 210e562.

📒 Files selected for processing (1)
  • src/hooks/useGitHubAuth.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Session Timeout Not Implemented - Sessions Never Expire

1 participant