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

Provide a logout method on the SDK #550

Closed
2 tasks done
IgnisDa opened this issue Feb 3, 2023 · 4 comments
Closed
2 tasks done

Provide a logout method on the SDK #550

IgnisDa opened this issue Feb 3, 2023 · 4 comments
Labels
enhancement New feature or request

Comments

@IgnisDa
Copy link
Contributor

IgnisDa commented Feb 3, 2023

Checklist

  • I could not find a solution in the existing issues or docs.
  • I agree to follow this project's Code of Conduct.

Description

It would be great if the Hanko SDK provided a logout method that would remove the hanko_cookie from the frontend.

Describe your ideal solution

Ideally this can be a part of the UserClient.

Workarounds or alternatives

No response

Hanko Version

v0.3.2

Additional Context

No response

@IgnisDa IgnisDa added the enhancement New feature or request label Feb 3, 2023
@irby
Copy link
Collaborator

irby commented Feb 9, 2023

I wrote a similar logout method for this project when I forked this project a while ago. I can throw together something that should get logout functionality available from the SDK.

@IgnisDa
Copy link
Contributor Author

IgnisDa commented Feb 9, 2023

@irby Could you please provide the code that does that? I would like to add it manually to my code until you make a PR (or I could make a PR too if you want). Thanks!

@irby
Copy link
Collaborator

irby commented Feb 9, 2023

@IgnisDa I'm about 85% done with the PR, and should have it posted here in the next day or so. But, here's the code I wrote some months ago that will expose an endpoint to log out the user.

Updating the Session Manager to have a DeleteCookie method: https://github.com/irby/passwordless-authenticator-poc/blob/main/authenticator-backend/session/session.go#L182 (Note updating the Manager interface on line 19)

Adding the DeleteCookie method within the Webauthn Test: https://github.com/irby/passwordless-authenticator-poc/blob/main/authenticator-backend/handler/webauthn_test.go#L203

Adding a logout method on user handler: https://github.com/irby/passwordless-authenticator-poc/blob/main/authenticator-backend/handler/user.go#L545

Logout endpoint exposed on the public server: https://github.com/irby/passwordless-authenticator-poc/blob/main/authenticator-backend/server/public_router.go#L69

Once this is added, you should be able to call the logout with POST /users/logout.

While making my PR, I noted some opportunities to improve my code. So, my PR will have some different code than what is in here. Just FYI 😅

@bjoern-m
Copy link
Contributor

bjoern-m commented Mar 3, 2023

Hello everyone!

The logout feature has been merged and the next release will take place next week.

Thanks for contributing!

@bjoern-m bjoern-m closed this as completed Mar 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

No branches or pull requests

3 participants