Skip to content

refactor(signIn): add strict validation for redirect values#83

Merged
halvaradop merged 3 commits intomasterfrom
refactor/add-strict-paths
Feb 2, 2026
Merged

refactor(signIn): add strict validation for redirect values#83
halvaradop merged 3 commits intomasterfrom
refactor/add-strict-paths

Conversation

@halvaradop
Copy link
Member

Description

This pull request adds strict validation for redirect values accepted by the /signIn/:provider endpoint, which is used to redirect users after a successful OAuth sign-in.

The refactor introduces a secure validation mechanism that compares the redirectTo search parameter against the Referer and Origin request headers. This ensures that only legitimate and safe URLs are allowed, preventing open redirect vulnerabilities.

The new validation logic guarantees that redirect values:

  • Contain only safe characters
  • Follow a valid URL format
  • Are consistent with the request origin

Validation Rules

The redirect target is considered valid only if it matches one of the following cases:

  • Relative paths

    • Must contain only safe characters
    • Must not include protocol or domain information
  • Absolute URLs

    • Must be a valid URL
    • Must share the same origin as the incoming request (origin check enforced)

This change significantly improves the security model of the OAuth sign-in flow by ensuring redirects cannot be abused for malicious navigation.

@vercel
Copy link

vercel bot commented Jan 31, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
auth-nextjs-demo Ready Ready Preview, Comment Feb 2, 2026 0:03am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
auth Skipped Skipped Feb 2, 2026 0:03am

@halvaradop halvaradop added refactor Refactor without changing behavior enhancement New feature or request and removed refactor Refactor without changing behavior labels Feb 1, 2026
@vercel vercel bot temporarily deployed to Preview – auth February 2, 2026 00:02 Inactive
@halvaradop halvaradop merged commit c0a8124 into master Feb 2, 2026
6 checks passed
@halvaradop halvaradop deleted the refactor/add-strict-paths branch February 2, 2026 14:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant