Skip to content
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

Added WebAuth Auth0 Session Clear #115

Merged
merged 3 commits into from
May 17, 2017
Merged

Added WebAuth Auth0 Session Clear #115

merged 3 commits into from
May 17, 2017

Conversation

cocojoe
Copy link
Member

@cocojoe cocojoe commented May 9, 2017

This call is silent/hidden with no redirect as it's not a web app so the only requirement, there is a callback so the user can do something if they want to from the result.

Copy link
Member

@hzalaz hzalaz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small detail in the comment the rest looks good. I have only one doubt, what is the user interaction with the logout?

@@ -194,3 +201,19 @@ private func generateDefaultState() -> String? {
guard result == 0 else { return nil }
return data.a0_encodeBase64URLSafe()
}

private class SilentSFSafariViewController: SFSafariViewController, SFSafariViewControllerDelegate {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this so a diff file

@cocojoe
Copy link
Member Author

cocojoe commented May 9, 2017

@hzalaz I would say it's as good as transparent, you can see it faintly at the top.
logout

- parameter federated: Bool to enable signout of the IdP
- parameter callback: callback called with the result of the logout
*/
func clearSession(useFederated federated: Bool, callback: @escaping (Bool) -> Void)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just federated and probably make it an optional parameter

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Originally was going to default to false (not a fan of optional booleans) then thought the user should understand what method they are calling.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All good making it mandatory then

@@ -200,4 +200,20 @@ public protocol WebAuth: Trackable, Loggable {
- parameter callback: callback called with the result of the WebAuth flow
*/
func start(_ callback: @escaping (Result<Credentials>) -> Void)

/**
Clear the SSO Cookie in Auth0 and optionally signout from IdP.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removes Auth0 session and optionally allows to remove the Identity Provider session.


/**
Clear the SSO Cookie in Auth0 and optionally signout from IdP.
More info: https://auth0.com/docs/logout
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use note or seeAlso like in the rest of the docs of the public API

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annoyingly, seeAlso appears to be broken in Xcode, few bug reports out there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, they changed the parser yet again

self.modalPresentationStyle = .overCurrentContext
}

func safariViewController(_ controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if it fails? should we handle that case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure I understand, the controller is dismissed and the success status didLoadSuccessfully is returned in the callback.
Are you saying we should wrap it into an Error type for coding style?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the url is invalid? if there is no internet connection? what will happened then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the URL called in the SFSafariViewController responds with anything other than HTTP 200 OK the callback will return false. (Have also manually tested this).

Auth0.podspec Outdated
@@ -10,6 +10,7 @@ web_auth_files = [
'Auth0/WebAuthError.swift',
'Auth0/SafariWebAuth.swift',
'Auth0/SafariSession.swift',
'SilentSafariViewController.swift',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why its in the root and not with the rest ?

@cocojoe cocojoe changed the title Added webauth logout Added WebAuth Auth0 Session Clear May 17, 2017
@cocojoe cocojoe merged commit ccef650 into master May 17, 2017
@cocojoe cocojoe added this to the v1-Next milestone Jun 5, 2017
@hzalaz hzalaz deleted the added-webauth-logout branch June 6, 2017 04:51
@cocojoe cocojoe mentioned this pull request Jun 6, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants