ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
50 stars 49 forks source link

Feature Request: Generalize URL launch and redirect listening #49

Closed Adelzm closed 1 year ago

Adelzm commented 1 year ago

First and foremost, I'd like to thank you for your work on this package. The feature of launching a URL and listening for the redirect URL across iOS, Android, and Web platforms is a standout feature and works brilliantly.

I'm reaching out to propose a possible extension of this functionality. While this feature is primarily used for authenticating users, it also has potential utility in other scenarios. One such instance is user sign-out.

In my application, I need to sign users out by redirecting them to a specific logout URL, and then ensure that the sign-out was successful by listening for a redirect URL from the server. As the flutter_web_auth_2 package already has the underlying mechanics to perform this, it would be incredibly useful if this functionality could be generalized to handle such cases.

I look forward to hearing your thoughts on this proposal. Thank you for your time and consideration.

ThexXTURBOXx commented 1 year ago

Thank you very much! :)

I think, this could be already done using the current approach by just calling authenticate with the logout URL. You should also configure your app to listen to redirects from your logout URL scheme using, e.g., on Android another data segment in the intent filter

Adelzm commented 1 year ago

Thank you for your quick reply. Your suggestion was indeed my initial assumption. I tested the method of calling authenticate with the logout URL and it performed as expected on both iOS and Android platforms.

However, I am encountering an issue when implementing the same procedure on the Web. Unlike the login process, during logout, the provider's Sign Out page doesn't close as anticipated. Instead, it redirects to my web page while leaving the my original webpage hanging. This is disrupting the logic of the logout operation.

I have created a 'logout.html' file in the './web' directory and then using the following logout redirect URL: https://mydomain.com/logout.html. Could this be causing the issue, considering I am using 'logout.html' instead of the 'auth.html' typically used for the processes?

ThexXTURBOXx commented 1 year ago

Okay, very nice to hear that it works as expected at least on iOS and Android.

For web, I am not sure why it does not work with another file which is not called auth.html since I do not check the file name at any point in the package, so it should not matter. Could it be possible that there is something else which is different with the logout.html page?

ThexXTURBOXx commented 1 year ago

This is partly fixed in 3.0.0-alpha.1 by adding a timeout option. The logout process should still work just as expected using a dedicated call to authenticate