-
Notifications
You must be signed in to change notification settings - Fork 2.1k
SignOut() without args is broken #6392
Comments
Potential fixes would be either adding a new DefaultSignOutScheme to Auth, or adding a check to require at least 1 scheme is specified. cc @Tratcher |
There already is a count check:
DefaultSignOutScheme, with a fallback to DefaultSignInScheme may be the best option. |
Is this really broken then? The error message is clear I would assume given the resource name: "MustSpecifyAtLeastOneAuthenticationScheme". Neither of the default schemes are required to be set, so this exception would be still sometimes get hit. We don't currently have an extension method for SignOut without a scheme either (https://github.com/aspnet/HttpAbstractions/blob/dev/src/Microsoft.AspNetCore.Authentication.Abstractions/AuthenticationHttpContextExtensions.cs#L151). We should be consistent regardless. If we do add a DefaultSignOutScheme that falls back to DefaultSignInScheme, we should probably just add one for Forbid too so we have one for each method on IAuthenticationService. |
This is what surprised me. The fact that the extension method required a string and the |
I guess there's another option too, which is eliminating the ability to pass in an arbitrary number of schemes, and only have 2 SignOutResult ctors: (string) and (string, AuthenticationProperties) |
Downside would be this would be a breaking change for MVC Well I found Pinpoint's PR that added these, looks like we did go back and forth and all around on this #4259 (comment) I knew we debated these overloads...bleh |
Heh we still have an open issue related to this in HttpAbstractions even aspnet/HttpAbstractions#585 |
cc @PinpointTownes since it was initially his sugar PR |
Nooooooo, please. I use this syntax almost in every app I develop 😅 E.g:
|
Signout is harder than signin |
Ok, since the sugar is useful, we could always do something kinda weird with SignOut in BaseController to require at least one scheme...
This forces a scheme and still lets you specify as many as you want... |
Adding a |
So to summarize the new behavior:
@davidfowl does that address your concerns? |
@HaoK you get a bonus point if you add a parameterless constructor for |
@HaoK - what further work do we need to do in MVC? |
I'll submit a PR, just need a few overloads I think |
Is this on track for 2.0.0? What's the importance of this? |
The MVC changes are just minor sugar, the auth changes that these are dependent on will go in today/tomorrow |
This logic passes an empty array for
authenticationSchemes
which blows up now.Mvc/src/Microsoft.AspNetCore.Mvc.Core/ControllerBase.cs
Line 1606 in 3e8cd1e
/cc @HaoK
The text was updated successfully, but these errors were encountered: