Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Store IP during signups, restrict tokens to IPs #1701

Closed

Conversation

AritraDey-Dev
Copy link

@AritraDey-Dev AritraDey-Dev commented Jan 6, 2025

Fixes #1613

Add IP address to JWT payload and session user during signups and logins.

  • src/lib/auth.ts

    • Add IP address to session user, token, and user interfaces.
    • Include IP address in JWT payload during signups and logins.
    • Retrieve user's IP address from request headers during authorization.
    • Store IP address in user object during login.
  • src/middleware.ts

    • Add IP address to user interface.
    • Check if the IP address matches the one in the JWT payload.
    • Redirect to invalid session page if IP address doesn't match.
  • src/actions/user/index.ts

    • Import FingerprintJS package.
    • Add function to store device and browser details during login.
    • Generate unique device ID using FingerprintJS.
    • Store device details in the user table.

For more details, open the Copilot Workspace session.

Fixes code100x#1613

Add IP address to JWT payload and session user during signups and logins.

* **src/lib/auth.ts**
  - Add IP address to session user, token, and user interfaces.
  - Include IP address in JWT payload during signups and logins.
  - Retrieve user's IP address from request headers during authorization.
  - Store IP address in user object during login.

* **src/middleware.ts**
  - Add IP address to user interface.
  - Check if the IP address matches the one in the JWT payload.
  - Redirect to invalid session page if IP address doesn't match.

* **src/actions/user/index.ts**
  - Import FingerprintJS package.
  - Add function to store device and browser details during login.
  - Generate unique device ID using FingerprintJS.
  - Store device details in the user table.

---

For more details, open the [Copilot Workspace session](https://copilot-workspace.githubnext.com/code100x/cms/issues/1613?shareId=XXXX-XXXX-XXXX-XXXX).
@devsargam devsargam closed this Jan 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Store IP during signups, restrict tokens to IPs
2 participants