We have a use-case where a re-authentication for confirmation needs to occur, and I was just popping up a login and making them login again, but because of short-circuit it always accepts it.
I don’t really want to log the user out completely beforehand, but don’t want them to proceed if they use the wrong password (and log them out in this case).
Seems like overriding IsAuthorized of my CredentialsAuthProvider is the best place?
Your custom AuthProvider wont get called if they’re already authenticated.
Sounds like you just want to logout on any Authentication attempt? In which case you can add a Global Request Filter to log the user out for any POST Authenticate request, e.g something like:
GlobalRequestFilters.Add((req,res,dto) => {
if (dto is Authenticate && req.Verb == HttpMethods.Post)
req.RemoveSession();
});
Yeah it calls IsAuthorized() first to determine whether to TryAuthenticate or not. The default impl is to return true for authenticated users which will short-circuit Authentication.