fix: preserve double slashes in custom scheme redirect URIs#2598
Open
gourabsingha1 wants to merge 1 commit into
Open
fix: preserve double slashes in custom scheme redirect URIs#2598gourabsingha1 wants to merge 1 commit into
gourabsingha1 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This pull request fixes the issue where custom scheme redirect URIs without a path component (e.g.
myapp://) are corrupted during OAuth and PKCE verification flow redirects.Root Cause
Go's standard library
net/urlparser treats a bare custom scheme without a host (likemyapp://) as having an empty host component. When the URL is re-serialized usingu.String(), it drops the//authority separator, transformingmyapp://?code=xxxintomyapp:?code=xxx. Furthermore,http.Redirectparses the target redirect URL and normalizes it usingu.String(), causing any manually fixed string URLs to be corrupted again during header construction.Solution
prepPKCERedirectURLandprepRedirectURLininternal/api/verify.goto reconstruct and restore double slashes when Go's standard library serialization drops them on empty-host custom schemes.API.redirecthelper method that sets theLocationheader directly on the response writer, bypassinghttp.Redirect's re-serialization normalization.verify.go,external.go, andsamlacs.goto utilizea.redirect.Fixes #2423