Remove old 1.x auth stack (#4485)

* Remove old 1.x auth stack

Fixes https://github.com/aspnet/AspNetCore/issues/3999
This commit is contained in:
Hao Kung 2019-01-09 15:56:19 -08:00 committed by GitHub
parent ea344bf726
commit d7a7c65b2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
31 changed files with 115 additions and 860 deletions

View File

@ -1,29 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Security.Claims;
namespace Microsoft.AspNetCore.Http.Authentication
{
/// <summary>
/// Used to store the results of an Authenticate call.
/// </summary>
public class AuthenticateInfo
{
/// <summary>
/// The <see cref="ClaimsPrincipal"/>.
/// </summary>
public ClaimsPrincipal Principal { get; set; }
/// <summary>
/// The <see cref="AuthenticationProperties"/>.
/// </summary>
public AuthenticationProperties Properties { get; set; }
/// <summary>
/// The <see cref="AuthenticationDescription"/>.
/// </summary>
public AuthenticationDescription Description { get; set; }
}
}

View File

@ -1,68 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Globalization;
namespace Microsoft.AspNetCore.Http.Authentication
{
/// <summary>
/// Contains information describing an authentication provider.
/// </summary>
public class AuthenticationDescription
{
private const string DisplayNamePropertyKey = "DisplayName";
private const string AuthenticationSchemePropertyKey = "AuthenticationScheme";
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
/// </summary>
public AuthenticationDescription()
: this(items: null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationDescription"/> class
/// </summary>
/// <param name="items"></param>
public AuthenticationDescription(IDictionary<string, object> items)
{
Items = items ?? new Dictionary<string, object>(StringComparer.Ordinal); ;
}
/// <summary>
/// Contains metadata about the authentication provider.
/// </summary>
public IDictionary<string, object> Items { get; }
/// <summary>
/// Gets or sets the name used to reference the authentication middleware instance.
/// </summary>
public string AuthenticationScheme
{
get { return GetString(AuthenticationSchemePropertyKey); }
set { Items[AuthenticationSchemePropertyKey] = value; }
}
/// <summary>
/// Gets or sets the display name for the authentication provider.
/// </summary>
public string DisplayName
{
get { return GetString(DisplayNamePropertyKey); }
set { Items[DisplayNamePropertyKey] = value; }
}
private string GetString(string name)
{
object value;
if (Items.TryGetValue(name, out value))
{
return Convert.ToString(value, CultureInfo.InvariantCulture);
}
return null;
}
}
}

View File

@ -1,132 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http.Features.Authentication;
namespace Microsoft.AspNetCore.Http.Authentication
{
[Obsolete("This is obsolete and will be removed in a future version. See https://go.microsoft.com/fwlink/?linkid=845470.")]
public abstract class AuthenticationManager
{
/// <summary>
/// Constant used to represent the automatic scheme
/// </summary>
public const string AutomaticScheme = "Automatic";
public abstract HttpContext HttpContext { get; }
public abstract IEnumerable<AuthenticationDescription> GetAuthenticationSchemes();
public abstract Task<AuthenticateInfo> GetAuthenticateInfoAsync(string authenticationScheme);
// Will remove once callees have been updated
public abstract Task AuthenticateAsync(AuthenticateContext context);
public virtual async Task<ClaimsPrincipal> AuthenticateAsync(string authenticationScheme)
{
return (await GetAuthenticateInfoAsync(authenticationScheme))?.Principal;
}
public virtual Task ChallengeAsync()
{
return ChallengeAsync(properties: null);
}
public virtual Task ChallengeAsync(AuthenticationProperties properties)
{
return ChallengeAsync(authenticationScheme: AutomaticScheme, properties: properties);
}
public virtual Task ChallengeAsync(string authenticationScheme)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
return ChallengeAsync(authenticationScheme: authenticationScheme, properties: null);
}
// Leave it up to authentication handler to do the right thing for the challenge
public virtual Task ChallengeAsync(string authenticationScheme, AuthenticationProperties properties)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
return ChallengeAsync(authenticationScheme, properties, ChallengeBehavior.Automatic);
}
public virtual Task SignInAsync(string authenticationScheme, ClaimsPrincipal principal)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
if (principal == null)
{
throw new ArgumentNullException(nameof(principal));
}
return SignInAsync(authenticationScheme, principal, properties: null);
}
/// <summary>
/// Creates a challenge for the authentication manager with <see cref="ChallengeBehavior.Forbidden"/>.
/// </summary>
/// <returns>A <see cref="Task"/> that represents the asynchronous challenge operation.</returns>
public virtual Task ForbidAsync()
=> ForbidAsync(AutomaticScheme, properties: null);
public virtual Task ForbidAsync(string authenticationScheme)
{
if (authenticationScheme == null)
{
throw new ArgumentNullException(nameof(authenticationScheme));
}
return ForbidAsync(authenticationScheme, properties: null);
}
// Deny access (typically a 403)
public virtual Task ForbidAsync(string authenticationScheme, AuthenticationProperties properties)
{
if (authenticationScheme == null)
{
throw new ArgumentNullException(nameof(authenticationScheme));
}
return ChallengeAsync(authenticationScheme, properties, ChallengeBehavior.Forbidden);
}
/// <summary>
/// Creates a challenge for the authentication manager with <see cref="ChallengeBehavior.Forbidden"/>.
/// </summary>
/// <param name="properties">Additional arbitrary values which may be used by particular authentication types.</param>
/// <returns>A <see cref="Task"/> that represents the asynchronous challenge operation.</returns>
public virtual Task ForbidAsync(AuthenticationProperties properties)
=> ForbidAsync(AutomaticScheme, properties);
public abstract Task ChallengeAsync(string authenticationScheme, AuthenticationProperties properties, ChallengeBehavior behavior);
public abstract Task SignInAsync(string authenticationScheme, ClaimsPrincipal principal, AuthenticationProperties properties);
public virtual Task SignOutAsync(string authenticationScheme)
{
if (authenticationScheme == null)
{
throw new ArgumentNullException(nameof(authenticationScheme));
}
return SignOutAsync(authenticationScheme, properties: null);
}
public abstract Task SignOutAsync(string authenticationScheme, AuthenticationProperties properties);
}
}

View File

@ -1,197 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Globalization;
namespace Microsoft.AspNetCore.Http.Authentication
{
/// <summary>
/// Dictionary used to store state values about the authentication session.
/// </summary>
public class AuthenticationProperties
{
internal const string IssuedUtcKey = ".issued";
internal const string ExpiresUtcKey = ".expires";
internal const string IsPersistentKey = ".persistent";
internal const string RedirectUriKey = ".redirect";
internal const string RefreshKey = ".refresh";
internal const string UtcDateTimeFormat = "r";
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationProperties"/> class
/// </summary>
public AuthenticationProperties()
: this(items: null)
{
}
/// <summary>
/// Initializes a new instance of the <see cref="AuthenticationProperties"/> class
/// </summary>
/// <param name="items"></param>
public AuthenticationProperties(IDictionary<string, string> items)
{
Items = items ?? new Dictionary<string, string>(StringComparer.Ordinal);
}
/// <summary>
/// State values about the authentication session.
/// </summary>
public IDictionary<string, string> Items { get; }
/// <summary>
/// Gets or sets whether the authentication session is persisted across multiple requests.
/// </summary>
public bool IsPersistent
{
get { return Items.ContainsKey(IsPersistentKey); }
set
{
if (Items.ContainsKey(IsPersistentKey))
{
if (!value)
{
Items.Remove(IsPersistentKey);
}
}
else
{
if (value)
{
Items.Add(IsPersistentKey, string.Empty);
}
}
}
}
/// <summary>
/// Gets or sets the full path or absolute URI to be used as an HTTP redirect response value.
/// </summary>
public string RedirectUri
{
get
{
string value;
return Items.TryGetValue(RedirectUriKey, out value) ? value : null;
}
set
{
if (value != null)
{
Items[RedirectUriKey] = value;
}
else
{
if (Items.ContainsKey(RedirectUriKey))
{
Items.Remove(RedirectUriKey);
}
}
}
}
/// <summary>
/// Gets or sets the time at which the authentication ticket was issued.
/// </summary>
public DateTimeOffset? IssuedUtc
{
get
{
string value;
if (Items.TryGetValue(IssuedUtcKey, out value))
{
DateTimeOffset dateTimeOffset;
if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset))
{
return dateTimeOffset;
}
}
return null;
}
set
{
if (value.HasValue)
{
Items[IssuedUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
}
else
{
if (Items.ContainsKey(IssuedUtcKey))
{
Items.Remove(IssuedUtcKey);
}
}
}
}
/// <summary>
/// Gets or sets the time at which the authentication ticket expires.
/// </summary>
public DateTimeOffset? ExpiresUtc
{
get
{
string value;
if (Items.TryGetValue(ExpiresUtcKey, out value))
{
DateTimeOffset dateTimeOffset;
if (DateTimeOffset.TryParseExact(value, UtcDateTimeFormat, CultureInfo.InvariantCulture, DateTimeStyles.RoundtripKind, out dateTimeOffset))
{
return dateTimeOffset;
}
}
return null;
}
set
{
if (value.HasValue)
{
Items[ExpiresUtcKey] = value.Value.ToString(UtcDateTimeFormat, CultureInfo.InvariantCulture);
}
else
{
if (Items.ContainsKey(ExpiresUtcKey))
{
Items.Remove(ExpiresUtcKey);
}
}
}
}
/// <summary>
/// Gets or sets if refreshing the authentication session should be allowed.
/// </summary>
public bool? AllowRefresh
{
get
{
string value;
if (Items.TryGetValue(RefreshKey, out value))
{
bool refresh;
if (bool.TryParse(value, out refresh))
{
return refresh;
}
}
return null;
}
set
{
if (value.HasValue)
{
Items[RefreshKey] = value.Value.ToString();
}
else
{
if (Items.ContainsKey(RefreshKey))
{
Items.Remove(RefreshKey);
}
}
}
}
}
}

View File

@ -5,7 +5,6 @@ using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Threading;
using Microsoft.AspNetCore.Http.Authentication;
using Microsoft.AspNetCore.Http.Features;
namespace Microsoft.AspNetCore.Http

View File

@ -0,0 +1,23 @@
[
{
"TypeId": "public abstract class Microsoft.AspNetCore.Http.Authentication.AuthenticationManager",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Authentication.AuthenticateInfo",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties",
"Kind": "Removal"
},
{
"TypeId": "public abstract class Microsoft.AspNetCore.Http.HttpContext",
"MemberId": "public abstract Microsoft.AspNetCore.Http.Authentication.AuthenticationManager get_Authentication()",
"Kind": "Removal"
}
]

View File

@ -1,69 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Security.Claims;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public class AuthenticateContext
{
public AuthenticateContext(string authenticationScheme)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
AuthenticationScheme = authenticationScheme;
}
public string AuthenticationScheme { get; }
public bool Accepted { get; private set; }
public ClaimsPrincipal Principal { get; private set; }
public IDictionary<string, string> Properties { get; private set; }
public IDictionary<string, object> Description { get; private set; }
public Exception Error { get; private set; }
public virtual void Authenticated(ClaimsPrincipal principal, IDictionary<string, string> properties, IDictionary<string, object> description)
{
Accepted = true;
Principal = principal;
Properties = properties;
Description = description;
// Set defaults for fields we don't use in case multiple handlers modified the context.
Error = null;
}
public virtual void NotAuthenticated()
{
Accepted = true;
// Set defaults for fields we don't use in case multiple handlers modified the context.
Description = null;
Error = null;
Principal = null;
Properties = null;
}
public virtual void Failed(Exception error)
{
Accepted = true;
Error = error;
// Set defaults for fields we don't use in case multiple handlers modified the context.
Description = null;
Principal = null;
Properties = null;
}
}
}

View File

@ -1,12 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public enum ChallengeBehavior
{
Automatic,
Unauthorized,
Forbidden
}
}

View File

@ -1,41 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public class ChallengeContext
{
public ChallengeContext(string authenticationScheme)
: this(authenticationScheme, properties: null, behavior: ChallengeBehavior.Automatic)
{
}
public ChallengeContext(string authenticationScheme, IDictionary<string, string> properties, ChallengeBehavior behavior)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
AuthenticationScheme = authenticationScheme;
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
Behavior = behavior;
}
public string AuthenticationScheme { get; }
public ChallengeBehavior Behavior { get; }
public IDictionary<string, string> Properties { get; }
public bool Accepted { get; private set; }
public void Accept()
{
Accepted = true;
}
}
}

View File

@ -1,27 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public class DescribeSchemesContext
{
private List<IDictionary<string, object>> _results;
public DescribeSchemesContext()
{
_results = new List<IDictionary<string, object>>();
}
public IEnumerable<IDictionary<string, object>> Results
{
get { return _results; }
}
public void Accept(IDictionary<string, object> description)
{
_results.Add(description);
}
}
}

View File

@ -1,20 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public interface IAuthenticationHandler
{
void GetDescriptions(DescribeSchemesContext context);
Task AuthenticateAsync(AuthenticateContext context);
Task ChallengeAsync(ChallengeContext context);
Task SignInAsync(SignInContext context);
Task SignOutAsync(SignOutContext context);
}
}

View File

@ -9,8 +9,5 @@ namespace Microsoft.AspNetCore.Http.Features.Authentication
public interface IHttpAuthenticationFeature
{
ClaimsPrincipal User { get; set; }
[Obsolete("This is obsolete and will be removed in a future version. See https://go.microsoft.com/fwlink/?linkid=845470.")]
IAuthenticationHandler Handler { get; set; }
}
}
}

View File

@ -1,42 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Security.Claims;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public class SignInContext
{
public SignInContext(string authenticationScheme, ClaimsPrincipal principal, IDictionary<string, string> properties)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
if (principal == null)
{
throw new ArgumentNullException(nameof(principal));
}
AuthenticationScheme = authenticationScheme;
Principal = principal;
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
}
public string AuthenticationScheme { get; }
public ClaimsPrincipal Principal { get; }
public IDictionary<string, string> Properties { get; }
public bool Accepted { get; private set; }
public void Accept()
{
Accepted = true;
}
}
}

View File

@ -1,33 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public class SignOutContext
{
public SignOutContext(string authenticationScheme, IDictionary<string, string> properties)
{
if (string.IsNullOrEmpty(authenticationScheme))
{
throw new ArgumentException(nameof(authenticationScheme));
}
AuthenticationScheme = authenticationScheme;
Properties = properties ?? new Dictionary<string, string>(StringComparer.Ordinal);
}
public string AuthenticationScheme { get; }
public IDictionary<string, string> Properties { get; }
public bool Accepted { get; private set; }
public void Accept()
{
Accepted = true;
}
}
}

View File

@ -0,0 +1,58 @@
[
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.AuthenticateContext",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.ChallengeContext",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.DescribeSchemesContext",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Authentication.AuthenticateInfo",
{
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Authentication.AuthenticationDescription",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Authentication.AuthenticationProperties",
"Kind": "Removal"
},
{
"TypeId": "public abstract class Microsoft.AspNetCore.Http.HttpContext",
"MemberId": "public abstract Microsoft.AspNetCore.Http.Authentication.AuthenticationManager get_Authentication()",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.SignInContext",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.SignOutContext",
"Kind": "Removal"
},
{
"TypeId": "public enum Microsoft.AspNetCore.Http.Features.Authentication.ChallengeBehavior",
"Kind": "Removal"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler",
"Kind": "Removal"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature",
"MemberId": "Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler get_Handler()",
"Kind": "Removal"
},
{
"TypeId": "public interface Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature",
"MemberId": "System.Void set_Handler(Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler value)",
"Kind": "Removal"
}
]

View File

@ -1,162 +0,0 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Claims;
using System.Threading.Tasks;
using Xunit;
namespace Microsoft.AspNetCore.Http.Features.Authentication
{
public class AuthenticateContextTest
{
[Fact]
public void AuthenticateContext_Authenticated()
{
// Arrange
var context = new AuthenticateContext("test");
var principal = new ClaimsPrincipal();
var properties = new Dictionary<string, string>();
var description = new Dictionary<string, object>();
// Act
context.Authenticated(principal, properties, description);
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Same(description, context.Description);
Assert.Null(context.Error);
Assert.Same(principal, context.Principal);
Assert.Same(properties, context.Properties);
}
[Fact]
public void AuthenticateContext_Authenticated_SetsUnusedPropertiesToDefault()
{
// Arrange
var context = new AuthenticateContext("test");
var principal = new ClaimsPrincipal();
var properties = new Dictionary<string, string>();
var description = new Dictionary<string, object>();
context.Failed(new Exception());
// Act
context.Authenticated(principal, properties, description);
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Same(description, context.Description);
Assert.Null(context.Error);
Assert.Same(principal, context.Principal);
Assert.Same(properties, context.Properties);
}
[Fact]
public void AuthenticateContext_Failed()
{
// Arrange
var context = new AuthenticateContext("test");
var exception = new Exception();
// Act
context.Failed(exception);
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Null(context.Description);
Assert.Same(exception, context.Error);
Assert.Null(context.Principal);
Assert.Null(context.Properties);
}
[Fact]
public void AuthenticateContext_Failed_SetsUnusedPropertiesToDefault()
{
// Arrange
var context = new AuthenticateContext("test");
var exception = new Exception();
context.Authenticated(new ClaimsPrincipal(), new Dictionary<string, string>(), new Dictionary<string, object>());
// Act
context.Failed(exception);
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Null(context.Description);
Assert.Same(exception, context.Error);
Assert.Null(context.Principal);
Assert.Null(context.Properties);
}
[Fact]
public void AuthenticateContext_NotAuthenticated()
{
// Arrange
var context = new AuthenticateContext("test");
// Act
context.NotAuthenticated();
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Null(context.Description);
Assert.Null(context.Error);
Assert.Null(context.Principal);
Assert.Null(context.Properties);
}
[Fact]
public void AuthenticateContext_NotAuthenticated_SetsUnusedPropertiesToDefault_Authenticated()
{
// Arrange
var context = new AuthenticateContext("test");
var exception = new Exception();
context.Authenticated(new ClaimsPrincipal(), new Dictionary<string, string>(), new Dictionary<string, object>());
// Act
context.NotAuthenticated();
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Null(context.Description);
Assert.Null(context.Error);
Assert.Null(context.Principal);
Assert.Null(context.Properties);
}
[Fact]
public void AuthenticateContext_NotAuthenticated_SetsUnusedPropertiesToDefault_Failed()
{
// Arrange
var context = new AuthenticateContext("test");
context.Failed(new Exception());
context.NotAuthenticated();
// Assert
Assert.True(context.Accepted);
Assert.Equal("test", context.AuthenticationScheme);
Assert.Null(context.Description);
Assert.Null(context.Error);
Assert.Null(context.Principal);
Assert.Null(context.Properties);
}
}
}

View File

@ -96,7 +96,6 @@ namespace Microsoft.AspNetCore.Http
public override WebSocketManager WebSockets => _websockets ?? (_websockets = new DefaultWebSocketManager(_features.Collection));
public override ClaimsPrincipal User
{
get

View File

@ -12,11 +12,5 @@ namespace Microsoft.AspNetCore.Http.Features.Authentication
get;
set;
}
public IAuthenticationHandler Handler
{
get;
set;
}
}
}

View File

@ -0,0 +1,27 @@
[
{
"TypeId": "public class Microsoft.AspNetCore.Http.DefaultHttpContext : Microsoft.AspNetCore.Http.HttpContext",
"MemberId": "protected virtual Microsoft.AspNetCore.Http.Authentication.AuthenticationManager InitializeAuthenticationManager()",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.DefaultHttpContext : Microsoft.AspNetCore.Http.HttpContext",
"MemberId": "protected virtual System.Void UninitializeAuthenticationManager(Microsoft.AspNetCore.Http.Authentication.AuthenticationManager instance)",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.DefaultHttpContext : Microsoft.AspNetCore.Http.HttpContext",
"MemberId": "public override Microsoft.AspNetCore.Http.Authentication.AuthenticationManager get_Authentication()",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.HttpAuthenticationFeature : Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature",
"MemberId": "public Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler get_Handler()",
"Kind": "Removal"
},
{
"TypeId": "public class Microsoft.AspNetCore.Http.Features.Authentication.HttpAuthenticationFeature : Microsoft.AspNetCore.Http.Features.Authentication.IHttpAuthenticationFeature",
"MemberId": "public System.Void set_Handler(Microsoft.AspNetCore.Http.Features.Authentication.IAuthenticationHandler value)",
"Kind": "Removal"
}
]

View File

@ -279,8 +279,6 @@ namespace Microsoft.AspNetCore.Owin
}
}
IAuthenticationHandler IHttpAuthenticationFeature.Handler { get; set; }
/// <summary>
/// Gets or sets if the underlying server supports WebSockets. This is enabled by default.
/// The value should be consistent across requests.

View File

@ -2,6 +2,7 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading.Tasks;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authentication.Cookies;
namespace Microsoft.AspNetCore.Identity
@ -17,7 +18,7 @@ namespace Microsoft.AspNetCore.Identity
/// the identity.
/// </summary>
/// <param name="context">The context containing the <see cref="System.Security.Claims.ClaimsPrincipal"/>
/// and <see cref="Http.Authentication.AuthenticationProperties"/> to validate.</param>
/// and <see cref="AuthenticationProperties"/> to validate.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous validation operation.</returns>
Task ValidateAsync(CookieValidatePrincipalContext context);
}

View File

@ -94,7 +94,7 @@ namespace Microsoft.AspNetCore.Identity
/// the identity.
/// </summary>
/// <param name="context">The context containing the <see cref="System.Security.Claims.ClaimsPrincipal"/>
/// and <see cref="Http.Authentication.AuthenticationProperties"/> to validate.</param>
/// and <see cref="AuthenticationProperties"/> to validate.</param>
/// <returns>The <see cref="Task"/> that represents the asynchronous validation operation.</returns>
public virtual async Task ValidateAsync(CookieValidatePrincipalContext context)
{

View File

@ -2,7 +2,6 @@
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http.Authentication;
namespace Microsoft.AspNetCore.Authentication
{

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Http.Authentication;
namespace Microsoft.AspNetCore.Authentication
{

View File

@ -126,7 +126,7 @@ namespace Microsoft.AspNetCore.Authentication
/// <summary>
/// Defines whether access and refresh tokens should be stored in the
/// <see cref="Http.Authentication.AuthenticationProperties"/> after a successful authorization.
/// <see cref="AuthenticationProperties"/> after a successful authorization.
/// This property is set to <c>false</c> by default to reduce
/// the size of the final authentication cookie.
/// </summary>

View File

@ -101,7 +101,7 @@ namespace Microsoft.AspNetCore.Authentication.JwtBearer
/// <summary>
/// Defines whether the bearer token should be stored in the
/// <see cref="Http.Authentication.AuthenticationProperties"/> after a successful authorization.
/// <see cref="AuthenticationProperties"/> after a successful authorization.
/// </summary>
public bool SaveToken { get; set; } = true;

View File

@ -1,8 +1,6 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using Microsoft.AspNetCore.Http.Authentication;
namespace Microsoft.AspNetCore.Authentication.Twitter
{
/// <summary>

View File

@ -3,7 +3,6 @@
using System;
using System.IO;
using Microsoft.AspNetCore.Http.Authentication;
namespace Microsoft.AspNetCore.Authentication.Twitter
{

View File

@ -35,7 +35,7 @@ namespace Microsoft.AspNetCore.Authentication.Twitter
/// <summary>
/// Called when a Challenge causes a redirect to authorize endpoint in the Twitter handler
/// </summary>
/// <param name="context">Contains redirect URI and <see cref="Http.Authentication.AuthenticationProperties"/> of the challenge </param>
/// <param name="context">Contains redirect URI and <see cref="AuthenticationProperties"/> of the challenge </param>
public virtual Task RedirectToAuthorizationEndpoint(RedirectContext<TwitterOptions> context) => OnRedirectToAuthorizationEndpoint(context);
}
}

View File

@ -450,8 +450,6 @@ namespace Microsoft.AspNetCore.Server.HttpSys
set { _user = value; }
}
IAuthenticationHandler IHttpAuthenticationFeature.Handler { get; set; }
string IHttpRequestIdentifierFeature.TraceIdentifier
{
get

View File

@ -195,8 +195,6 @@ namespace Microsoft.AspNetCore.Server.IIS.Core
set => User = value;
}
public IAuthenticationHandler Handler { get; set; }
string IServerVariablesFeature.this[string variableName]
{
get