-
Notifications
You must be signed in to change notification settings - Fork 278
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
As web authentication presentation context providing #327
As web authentication presentation context providing #327
Conversation
Since iOS 13, ASWebAuthenticationSession requires that a presentation context is provided in order to present the authentication UI. This context (`ASWebPresentationAnchor`) is typealiased to `UIWindow` on iOS. This commit implements the necessary provider by returning the `authorizeContext` from `OAuath2Config`.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems incomplete - where are the changes to authConfig?
Documentation should be added for the new field.
The only new field I added was /// Used to store the ASWebAuthenticationPresentationContextProvider
private var webAuthenticationPresentationContextProvider: AnyObject? Which I added a doc line for the same as the other properties in that class, but it's private, so shouldn't need too much documentation as it's not part of the public API that users would interact with. There were no changes necessary to the authConfig, as this uses the already existing This PR just exposes the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved - I'm facing the same issue when building with iOS 13 SDK.
I am getting some errors: It would be nice to get this fixed and merged soon EDIT: This error only happens when I point Swift Package Manager to Jame's repo and branch. If I point it to the latest version (5.1) it works. Not sure why Swift Package Manager complains about it |
@fotiDim This PR is branched from master. the 5.1 release is a couple of commits behind master. One of the commits since the 5.1 release mentions swift PM config changes. That's probably your issue and I don't believe it's related to this PR itself. |
@james-rantmedia can you merge upstream master on your branch so that I can test? |
@james-rantmedia @larrybrunet I narrowed it down being the |
34b4fe2
to
5e2f70d
Compare
Version 5.1.1 has these errors fixed! |
Hi, is anybody checking this issue? seems like version 5.1.1 is not working, it failed in the CI |
@ernestoSk13 that issue had been fixe, it was just the Travis config that we needed to update. |
I managed to get this branch to work, however, there's a fix needed for my code, before this, when I call authorizeEmbedded, I pass in the UIViewController as "from" parameter, which if I do useAuthenticationSession, it will complain that it is not a UIWindow. So I need to pass in self.view.window as the "from" parameter, then it will work. I suggest to make this automatic in the pull request, so that passing either UIViewController or UIWindow will both work. |
I faced situations where the authorizeContext is nil in presentationAnchor
|
Actually it is not nil, its just not a ASPresentationAnchor which is UIWindow. |
@@ -142,9 +145,10 @@ open class OAuth2Authorizer: OAuth2AuthorizerUI { | |||
self.oauth2.logger?.warn("OAuth2", msg: "Cannot intercept redirect URL: \(err)") | |||
} | |||
} else { | |||
self.oauth2.didFail(with: nil) | |||
self.oauth2.didFail(with: error?.asOAuth2Error) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that the oauth2
depends on this to be nil
in order to process and provide OAuth2Error.requestCancelled
error.
Please see Oauth2Base.didFail(with:)
method for details.
Since iOS 13, ASWebAuthenticationSession requires that a presentation context is provided in order to present the authentication UI. This context (
ASWebPresentationAnchor
) is typealiased toUIWindow
on iOS.This PR implements the necessary provider by returning the
authorizeContext
fromOAuath2Config
.I also return the
error.asOAuth2Error
in the completion handler, as without it the web authentication session was failing silently on iOS 13.