mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 20:55:57 +03:00
[GH-ISSUE #653] 🐛 Invalid URL built when ASWebAuthenticationSession returns an error #428
Labels
No labels
bug
cocoapod
duplicate
enhancement
feature-request
help wanted
help wanted
invalid
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/OAuthSwift#428
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Originally created by @phatblat on GitHub (May 3, 2021).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/653
Description:
When a non-nil error is returned to the
ASWebAuthenticationSessioncompletion handler provided by this library, a URL is built using only the scheme and some query string parameters.This results in a URL like the following being constructed:
Note that the
guard let url = URL(string: urlString)is not sufficient to catch this because theurlvariable does end up with an instance ofURL. The problem comes when the URL is opened withUIApplication.shared.open(url):Note that the success case is not affected as the
callbackURL passed to the completion handler is opened without any modification.OAuth Provider? (Twitter, Github, ..):
PingFederate
OAuth Version:
OS (Please fill the version) :
Installation method:
Library version:
Xcode version:
12.5 (Swift 5.4)
11.4 (Swift 5.2)
11.x (Swift 5.1)
10.x (Swift 5.0)
other: (Please fill in the version you are using.)
objective c
@phatblat commented on GitHub (May 3, 2021):
A big problem with the current approach of building callback URL with the error info is that this implementation assumes that the app is using a custom URL scheme. If the app were (only) using a universal link (
https://example.com/redirect) as their OAuthredirect_uri, then there would be no way to return the info to the app. A URL of "https?error=blah" will generate the same error:@phatblat commented on GitHub (May 3, 2021):
Since the full
redirect_uriisn't currently passed intoASWebAuthenticationURLHandler, it seems like the simplest tactical solution is to just insert:into this error URL.An API change would be required to add errors to the OAuth client's
redirect_uri@phatblat commented on GitHub (May 3, 2021):
I discovered this issue when we upgraded to using Xcode 12.5. We had been working around the issue by passing our OAuth client's redirect_uri as the
callbackURLScheme, but on iOS 14.5 this blows up:@phatblat commented on GitHub (May 4, 2021):
The issue with the
callbackURLSchemeis really an Apple API issue;ASWebAuthenticationURLHandleris merely a wrapper around it. Strange that Apple built this API without considering its own Universal Links technology, which would use redirect URLs with anhttpsscheme.