-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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
[API Proposal]: SignOut overloads that take only one authentication scheme #49391
Comments
Another: aspnetcore/src/Mvc/Mvc.Core/src/SignOutResult.cs Lines 41 to 42 in c343768
|
Thank you for submitting this for API review. This will be reviewed by @dotnet/aspnet-api-review at the next meeting of the ASP.NET Core API Review group. Please ensure you take a look at the API review process documentation and ensure that:
|
We have to be careful with default values. We do not to make We'll probably just have to leave out the default values. Which makes me wonder, if we should add just
What's the motivation for this considering the |
API Review Notes:
We tried to come up with an API proposal that would be non breaking. Below is as far as we got, but even this would probably break given a call like namespace Microsoft.AspNetCore.Http;
public static partial class Results
{
+ public static IResult SignOut()
- public static IResult SignOut(AuthenticationProperties? properties = null, IList<string>? authenticationSchemes = null)
+ public static IResult SignOut(AuthenticationProperties? properties, IList<string>? authenticationSchemes = null)
+ public static IResult SignOut(params string[] authenticationSchemes)
}
public static partial class TypedResults
{
+ public static SignOutHttpResult SignOut()
- public static SignOutHttpResult SignOut(AuthenticationProperties? properties = null, IList<string>? authenticationSchemes = null)
+ public static SignOutHttpResult SignOut(AuthenticationProperties? properties, IList<string>? authenticationSchemes = null)
+ public static SignOutHttpResult SignOut(params string[] authenticationSchemes)
} Because of the difficulty in maintaining backward compatibility, we've decided to reject the API. |
I guess C# 12 at least makes it slightly less ugly (and then maybe the compiler can optimise it?): app.MapGet("/signout", () =>
{
return TypedResults.SignOut(authenticationScheme: ["Cookies"]);
}); |
I agree it looks a bit better with the C# 12 syntax. The final iteration at our attempt at a non-breaking change might work if we renamed |
Background and Motivation
When multiple authentication schemes are registered, if we only want to sign out from a particular one it is necessary to allocate a collection. It is not the most efficient in terms of allocation.
aspnetcore/src/Http/Http.Results/src/Results.cs
Line 80 in c343768
aspnetcore/src/Http/Http.Results/src/TypedResults.cs
Line 84 in c343768
aspnetcore/src/Mvc/Mvc.Core/src/ControllerBase.cs
Line 2459 in c343768
Proposed API
Add overloads that take a single authentication scheme.
namespace Microsoft.AspNetCore.Mvc; public abstract partial class ControllerBase { + public virtual SignOutResult SignOut(string authenticationScheme) }
Usage Examples
Risks
Nothing I can see now
The text was updated successfully, but these errors were encountered: