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

Add WebAuth Logout feature #245

Merged
merged 8 commits into from
Jun 27, 2019
Merged

Add WebAuth Logout feature #245

merged 8 commits into from
Jun 27, 2019

Conversation

lbalmaceda
Copy link
Contributor

@lbalmaceda lbalmaceda commented Jun 25, 2019

Changes

This PR adds a static builder to launch a call to the /v2/logout endpoint.
Users can customize the scheme of the returnTo URL, and the Chrome Custom Tabs customization options, although TBH the process is quite fast and you barely notice the browser was open.

Usage

//log out method
Auth0 auth0 = getAccount();
WebAuthProvider.logout(auth0)
                .withScheme("demo")
                .start(this, logoutCallback);

//somewhere in the code
private VoidCallback logoutCallback = new VoidCallback() {
    @Override
    public void onFailure(Auth0Exception error) {
        //Browser app not found or logout canceled, check error message.
    }

    @Override
    public void onSuccess(Void payload) {
        //Logged out!
    }
};

Callback

The call can

  • succeed: when the browser invokes the returnTo URL and in turn, re-opens the user application.
  • fail:
    • when there is no browser app available,
    • or the user closes the browser manually. This last scenario is also triggered if the log out URL is not whitelisted in the application or tenant settings.

The log out URL will always include the client_id parameter. So the returnTo URL must be whitelisted in the application allowed logout URLs section on the dashboard. More info in auth0 docs.

References

Testing

Added a bunch of tests for the introduced changes.

Will probably rename some of the previous tests as now we share 2 flows (auth / logout) on the same WebAuthProvider class. (On a different PR)

  • This change adds unit test coverage

  • This change adds integration test coverage

  • This change has been tested on the latest version of the platform/language or why not

Checklist

@lbalmaceda lbalmaceda requested a review from a team June 25, 2019 15:52
@lbalmaceda lbalmaceda added the medium Medium review label Jun 25, 2019
@lbalmaceda lbalmaceda added this to the v1-Next milestone Jun 25, 2019
@joshcanhelp joshcanhelp requested review from joshcanhelp and removed request for a team June 26, 2019 14:20
@joshcanhelp joshcanhelp self-assigned this Jun 26, 2019
Copy link
Contributor

@jimmyjames jimmyjames left a comment

Choose a reason for hiding this comment

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

Looks good, just a few comments/suggestions around method names and the callback handler params.

Copy link
Contributor

@joshcanhelp joshcanhelp left a comment

Choose a reason for hiding this comment

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

Make sure you're following the docs styleguide for "logout" and "log out:"

https://github.com/auth0/docs/blob/master/STYLEGUIDE.md#vocabulary

All this makes me wonder if we want to expose the onFailure method or just expose the onSuccess method when we're confident that the returnTo URL was called because the user did log out.

Seems like there are enough conditions for failure that you would want to allow catching that. IMHO.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
@lbalmaceda lbalmaceda changed the title Add web auth logout feature Add WebAuth Logout feature Jun 27, 2019
@lbalmaceda lbalmaceda mentioned this pull request Jun 27, 2019
6 tasks
@damieng damieng merged commit 6e58493 into master Jun 27, 2019
@lbalmaceda lbalmaceda modified the milestones: v1-Next, 1.17.0 Jun 28, 2019
@lbalmaceda lbalmaceda deleted the webauth-logout branch January 20, 2021 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CH: Added medium Medium review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants