Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does LogoutPath do anything?

Tags:

c#

owin

I am writing a sample app. leveraging OWIN and UseCookieAuthentication. The latter accepts CookieAuthenticationOptions, which has a LogoutPath property. This property has the following associated note:

If the LogoutPath is provided the middleware then a request to that path will redirect based on the ReturnUrlParameter.

However, I cannot figure out whether this does anything or if it just represents some implicit contract your code will do something. For example, if I leverage AuthenticationManager.SignOut(), I would expect the logout-path endpoint would get called.

like image 689
Bill Boga Avatar asked Jan 30 '26 01:01

Bill Boga


1 Answers

Thanks to Khalid Abuhakmeh for providing additional insight. However, my confusion ultimately is a result of assuming an implicit end-point is mapped when specifying the LogoutPath property. After adding the following, requesting /logout?ReturnUrl=/ works as-expected:

app.Map("/logout", logout =>
{
    logout.Run(context =>
    {
        context.Authentication.SignOut();

        return Task.FromResult(0);
    });
});

Without the explicit map, I get a 404.

As an additional side-note, I also wrongly assumed providing an AuthenticationProperties-instance to SignOut would allow me to specify the return-url (instead of having it as part of the request url). It appears this only applies to external cookie authentication.

like image 163
Bill Boga Avatar answered Feb 01 '26 15:02

Bill Boga