-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Handle Default Authentication using events #16884
Conversation
How does using a middleware instead of a controller optimize performance? |
I agree with @Piedone, there's likely no gain at all to expect from a performance perspective. On the other hand, moving that to a middleware introduces new risks like responses collision (you're not checking whether the response has already been sent or not so you could potentially end up in a situation where your custom middleware will end up calling If performance was your main motivation for that, I'd say it's not worth the risk 😃 |
Quicker response time since it's done earlier on "before routing to a controller, and much less resource to create during the login request @kevinchalet main goal isn't performance here since this is only handled by one action. Main goal is to clean up the code so that the external authentication logic isn't coupled with the code in the Users feature. Also, to reduce the amount of code we used for the default login logic. |
Did you measure it? 😄 It's worth noting that middleware aren't really free. And unlike the existing approach, the price will now be paid for basically all requests (e.g you'll have to pay for the
In this case, why not an event? It's the good old way of doing things in Orchard 😃 |
No. Again, the idea behind this PR isn't optimization is more of decoupling the code. But, optimization and reducing allocations would be nice too.
I am open to ideas. How would we use handlers in this case challenge the request from an action? |
@kevinchalet I am now using event to handle this which simplifies the code and we won't need a middleware. |
@Piedone anything else to add here? |
src/OrchardCore/OrchardCore.Users.Abstractions/Events/LoginFormEventBase.cs
Outdated
Show resolved
Hide resolved
src/OrchardCore.Modules/OrchardCore.Users/Services/ExternalLoginFormEvents.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see there's no middleware anymore, so good enough for me :). Can't comment otherwise. |
We had a discussion about base classes during triage and decided (we forced Mike) to remove the base class. We think that we should accept base classes in these conditions:
|
By utilizing middleware instead of controllers for performance optimization, we can keep the login code streamlined and free from excessive external authentication logic.