mirror of
https://github.com/OAuthSwift/OAuthSwift.git
synced 2026-04-26 12:45:52 +03:00
[GH-ISSUE #621] ASWebAuthenticationSession support #403
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#403
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 @raxityo on GitHub (Aug 26, 2020).
Original GitHub issue: https://github.com/OAuthSwift/OAuthSwift/issues/621
Hi,
I see that we have
ASWebAuthenticationURLHandlerthat nicely supportsASWebAuthenticationSession.However, it has two limitations:
@available(iOS 13.0, ...).iOS 12.0+by preventing the use ofpresentationContextProviderandprefersEphemeralWebBrowserSession.Info.plistand update the app delegate to hand-off the callback toOAuthSwift.To overcome these limitations, I have added a class here. But if you guys think it can be helpful to be added in this library, I can create a PR in this repository.
Thanks!
@jrtibbetts commented on GitHub (May 9, 2021):
So was this class ever added to OAuthSwift? I wish it were.
@phatblat commented on GitHub (May 13, 2021):
@jrtibbetts
ASWebAuthenticationURLHandleris the library's wrapper forASWebAuthenticationSession. It has been a part of the library for a couple of years now.@phatblat commented on GitHub (May 13, 2021):
@raxityo If we downgrade the minimum version of iOS that this handler requires then we can't expose those newer properties you mention. I for one am looking forward to using the
prefersEphemeralWebBrowserSessionproperty to get rid of the alert that appears before the web page is loaded.Looking at your code, you didn't actually prevent the use of these properties, but rather only used them when on iOS 13.0+. This is a nice touch, but this OS-version-dependent behavior should certainly be documented. Would you be interested in opening a PR with this change?
Regarding the direct callback handoff, I am unsure whether this is the right way to handle this. When an app is using a custom URL scheme, this provides better security as it avoids the potential security issue where a second app implements the same URL scheme and intercepts the redirect.
However, if an app uses Universal Links (https://example.com/oauth2redirect?code=...), this might introduce an attack vector by not going through the iOS URL-loading system.
@raxityo commented on GitHub (May 13, 2021):
@phatblat For sure, I am happy to create a PR to update the current implementation of
ASWebAuthenticationURLHandlerand update the docs. 👍To address your concern about the direct hand-off:
When an app declares a custom URI scheme in
Info.plistto handle the auth callback, it opens the doors for other apps to communicate from the outside. WithASWebAuthenticationURLHandler, there's no need to declare the custom URI scheme in theInfo.plistor go through the AppDelegate to handle the custom URI scheme that eventually gets delivered toOAuthSwift. According to the docs ofASWebAuthenticationSession:As such, the custom URI scheme only gets shared to the
ASWebAuthenticationSession. 🙂@myihsan commented on GitHub (Feb 2, 2022):
@phatblat
This comment seems that you misunderstand the purpose of
ASWebAuthenticationSessionor there is a design change.I think
ASWebAuthenticationSessionis designed for using a custom URL without declaring it in theInfo.plistas @raxityo mentioned above.When using a universal link, we have to cancel the session by ourselves when
UIApplicationDelegate.application(_:open:options:)is called sincecompletionHandlerwill not be called even we setcallbackURLSchemeto"https". So, it's better to useSFSafariViewController.However, I have no idea why
callbackURLSchemecan benil.So it looks good to me to use
OAuthSwift.handle(url:)directly and needs to separatecallbackURLSchemefrom thecallbackURLused to create the error URL to avoid the issue you mentioned in the comment.I would like to create a PR if my understanding is correct.