I am trying to write a middleware which executes between authentication and authorization.
I've registered that middleware between these the two authXYZ:
app.UseAuthentication();
app.UseCustomMiddlerware();
app.UseAuthorization();
But I cannot get an authenticated user in my CustomMiddlerware.
When I deleted the app.UseAuthentication() statement then I found out that AuthenticationHandler still runs, and an authenticated user is available only after app.UseAuthorization().
So, here are my questions:
app.UseAuthorization() instead of using both app.UseAuthentication() and app.UseAuthorization()?Authentication and Authorization are two different things, but they also go hand in hand. Think of Authentication as letting someone into your home and Authorization as allowing your guests to do specific things once they’re inside (e.g. wear their shoes indoors, eat your food, etc). In other words, Authentication lets your web app’s users identify themselves to get access to your app and Authorization allows them to get access to specific features and functionality.
You can find more in here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With