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

[FR] Hooks for signup/login #120

Open
rafamel opened this issue Aug 6, 2019 · 3 comments
Open

[FR] Hooks for signup/login #120

rafamel opened this issue Aug 6, 2019 · 3 comments

Comments

@rafamel
Copy link

rafamel commented Aug 6, 2019

Hi there, excellent work!

I was thinking that in the same way we can currently set a passwordless endpoint to handle the token, it would be great if we could also define endpoints that ran on signup/login/logout/other actions.

This could be done either so the response from AuthN is independent of that endpoint response, or we could make the AuthN response fail too when the endpoint response does, which would also clear the path to (potentially) adding further data to the tokens, making #10 / #111 viable, while improving AuthN flexibility/possible use cases. With this flow, AuthN would pass the token data to the endpoint, which would in turn return the modified token data to be encrypted by AuthN and sent to the client.

It could also be used for custom email validations on signup, sending emails, adding custom rules for registration, et al.

What are your thoughts?

@cainlevy
Copy link
Member

cainlevy commented Aug 6, 2019

Yep! I'm noticing a pattern in requests for some kind of event bus. I think it would be a good extension point for AuthN, and could replace the webhooks that currently exist.

Do you have thoughts on what shape those events take or how they can integrate with a wide variety of systems?

@cainlevy
Copy link
Member

cainlevy commented Aug 6, 2019

@rafamel let's continue the discussion on #112

@cainlevy
Copy link
Member

cainlevy commented Aug 6, 2019

In response to #112 (comment):

Apologies for trying to merge this with an issue related to an event bus. Hooks are meaningfully different! I have a few points of caution here, so I'm looking to understand what new behavior they'll enable and be sure that hooks are the right way to address them.

My general concerns are:

  1. Increased coupling between AuthN and the main app (or services).
  2. Blocking on a synchronous API call. We'll need timeouts to guard against the increased latency. Would a failure cancel the user action?
  3. Hooks that do more than halt the user action will need bespoke response data for each intended use case. This has the potential for scope creep and an increase in AuthN's complexity.

I'm personally not very opinionated on the implementation details. I think that as long as they allow:

  • Control over AuthN response success/failure.
  • Preventing changes (updating data, registering a user...)
  • Control over token data.

Let's lay out the endpoints that should have hooks, with a use case for each.

You mentioned an implementation w/ HTTPS with Basic Auth. I'm not exactly sure of what the need for auth here would be, since events would only come from AuthN and not viceversa?

The app handling hooks needs to trust that they come from AuthN.

I was thinking about the specific timing for the events (after actions, before, or both)

I'd aim for before the action but after the validation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants