Skip to content

Add SignIn method without authentication scheme #23604

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

Merged
merged 2 commits into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/Mvc/Mvc.Core/ref/Microsoft.AspNetCore.Mvc.Core.netcoreapp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -541,10 +541,18 @@ protected ControllerBase() { }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.RedirectToRouteResult RedirectToRoutePreserveMethod(string routeName = null, object routeValues = null, string fragment = null) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignInResult SignIn(System.Security.Claims.ClaimsPrincipal principal) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignInResult SignIn(System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignInResult SignIn(System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Authentication.AuthenticationProperties properties, string authenticationScheme) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignInResult SignIn(System.Security.Claims.ClaimsPrincipal principal, string authenticationScheme) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignOutResult SignOut() { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignOutResult SignOut(Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignOutResult SignOut(Microsoft.AspNetCore.Authentication.AuthenticationProperties properties, params string[] authenticationSchemes) { throw null; }
[Microsoft.AspNetCore.Mvc.NonActionAttribute]
public virtual Microsoft.AspNetCore.Mvc.SignOutResult SignOut(params string[] authenticationSchemes) { throw null; }
Expand Down Expand Up @@ -1170,6 +1178,8 @@ public ServiceFilterAttribute(System.Type type) { }
}
public partial class SignInResult : Microsoft.AspNetCore.Mvc.ActionResult
{
public SignInResult(System.Security.Claims.ClaimsPrincipal principal) { }
public SignInResult(System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { }
public SignInResult(string authenticationScheme, System.Security.Claims.ClaimsPrincipal principal) { }
public SignInResult(string authenticationScheme, System.Security.Claims.ClaimsPrincipal principal, Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { }
public string AuthenticationScheme { [System.Runtime.CompilerServices.CompilerGeneratedAttribute] get { throw null; } [System.Runtime.CompilerServices.CompilerGeneratedAttribute] set { } }
Expand All @@ -1181,6 +1191,7 @@ public SignInResult(string authenticationScheme, System.Security.Claims.ClaimsPr
public partial class SignOutResult : Microsoft.AspNetCore.Mvc.ActionResult
{
public SignOutResult() { }
public SignOutResult(Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { }
public SignOutResult(System.Collections.Generic.IList<string> authenticationSchemes) { }
public SignOutResult(System.Collections.Generic.IList<string> authenticationSchemes, Microsoft.AspNetCore.Authentication.AuthenticationProperties properties) { }
public SignOutResult(string authenticationScheme) { }
Expand Down
38 changes: 38 additions & 0 deletions src/Mvc/Mvc.Core/src/ControllerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2386,6 +2386,15 @@ public virtual ForbidResult Forbid(AuthenticationProperties properties)
public virtual ForbidResult Forbid(AuthenticationProperties properties, params string[] authenticationSchemes)
=> new ForbidResult(authenticationSchemes, properties);

/// <summary>
/// Creates a <see cref="SignInResult"/>.
/// </summary>
/// <param name="principal">The <see cref="ClaimsPrincipal"/> containing the user claims.</param>
/// <returns>The created <see cref="SignInResult"/> for the response.</returns>
[NonAction]
public virtual SignInResult SignIn(ClaimsPrincipal principal)
=> new SignInResult(principal);

/// <summary>
/// Creates a <see cref="SignInResult"/> with the specified authentication scheme.
/// </summary>
Expand All @@ -2396,6 +2405,18 @@ public virtual ForbidResult Forbid(AuthenticationProperties properties, params s
public virtual SignInResult SignIn(ClaimsPrincipal principal, string authenticationScheme)
=> new SignInResult(authenticationScheme, principal);

/// <summary>
/// Creates a <see cref="SignInResult"/> with <paramref name="properties"/>.
/// </summary>
/// <param name="principal">The <see cref="ClaimsPrincipal"/> containing the user claims.</param>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the sign-in operation.</param>
/// <returns>The created <see cref="SignInResult"/> for the response.</returns>
[NonAction]
public virtual SignInResult SignIn(
ClaimsPrincipal principal,
AuthenticationProperties properties)
=> new SignInResult(principal, properties);

/// <summary>
/// Creates a <see cref="SignInResult"/> with the specified authentication scheme and
/// <paramref name="properties" />.
Expand All @@ -2411,6 +2432,23 @@ public virtual SignInResult SignIn(
string authenticationScheme)
=> new SignInResult(authenticationScheme, principal, properties);

/// <summary>
/// Creates a <see cref="SignOutResult"/>.
/// </summary>
/// <returns>The created <see cref="SignOutResult"/> for the response.</returns>
[NonAction]
public virtual SignOutResult SignOut()
=> new SignOutResult();

/// <summary>
/// Creates a <see cref="SignOutResult"/> with <paramref name="properties"/>.
/// </summary>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the sign-out operation.</param>
/// <returns>The created <see cref="SignOutResult"/> for the response.</returns>
[NonAction]
public virtual SignOutResult SignOut(AuthenticationProperties properties)
=> new SignOutResult(properties);

/// <summary>
/// Creates a <see cref="SignOutResult"/> with the specified authentication schemes.
/// </summary>
Expand Down
23 changes: 22 additions & 1 deletion src/Mvc/Mvc.Core/src/SignInResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ namespace Microsoft.AspNetCore.Mvc
/// </summary>
public class SignInResult : ActionResult
{
/// <summary>
/// Initializes a new instance of <see cref="SignInResult"/> with the
/// default authentication scheme.
/// </summary>
/// <param name="principal">The claims principal containing the user claims.</param>
public SignInResult(ClaimsPrincipal principal)
: this(authenticationScheme: null, principal, properties: null)
{
}

/// <summary>
/// Initializes a new instance of <see cref="SignInResult"/> with the
/// specified authentication scheme.
Expand All @@ -27,6 +37,17 @@ public SignInResult(string authenticationScheme, ClaimsPrincipal principal)
{
}

/// <summary>
/// Initializes a new instance of <see cref="SignInResult"/> with the
/// default authentication scheme and <paramref name="properties"/>.
/// </summary>
/// <param name="principal">The claims principal containing the user claims.</param>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the sign-in operation.</param>
public SignInResult(ClaimsPrincipal principal, AuthenticationProperties properties)
: this(authenticationScheme: null, principal, properties)
{
}

/// <summary>
/// Initializes a new instance of <see cref="SignInResult"/> with the
/// specified authentication scheme and <paramref name="properties"/>.
Expand All @@ -36,8 +57,8 @@ public SignInResult(string authenticationScheme, ClaimsPrincipal principal)
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the sign-in operation.</param>
public SignInResult(string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties)
{
AuthenticationScheme = authenticationScheme ?? throw new ArgumentNullException(nameof(authenticationScheme));
Principal = principal ?? throw new ArgumentNullException(nameof(principal));
AuthenticationScheme = authenticationScheme;
Properties = properties;
}

Expand Down
10 changes: 10 additions & 0 deletions src/Mvc/Mvc.Core/src/SignOutResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ public SignOutResult()
{
}

/// <summary>
/// Initializes a new instance of <see cref="SignOutResult"/> with the default sign out scheme.
/// specified authentication scheme and <paramref name="properties"/>.
/// </summary>
/// <param name="properties"><see cref="AuthenticationProperties"/> used to perform the sign-out operation.</param>
public SignOutResult(AuthenticationProperties properties)
: this(Array.Empty<string>(), properties)
{
}

/// <summary>
/// Initializes a new instance of <see cref="SignOutResult"/> with the
/// specified authentication scheme.
Expand Down