diff --git a/src/Http/Http.Abstractions/src/Authentication/AuthenticateInfo.cs b/src/Http/Http.Abstractions/src/Authentication/AuthenticateInfo.cs deleted file mode 100644 index 9e8e3fd53760..000000000000 --- a/src/Http/Http.Abstractions/src/Authentication/AuthenticateInfo.cs +++ /dev/null @@ -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 -{ - /// - /// Used to store the results of an Authenticate call. - /// - public class AuthenticateInfo - { - /// - /// The . - /// - public ClaimsPrincipal Principal { get; set; } - - /// - /// The . - /// - public AuthenticationProperties Properties { get; set; } - - /// - /// The . - /// - public AuthenticationDescription Description { get; set; } - } -} diff --git a/src/Http/Http.Abstractions/src/Authentication/AuthenticationDescription.cs b/src/Http/Http.Abstractions/src/Authentication/AuthenticationDescription.cs deleted file mode 100644 index fb0a073f0bbf..000000000000 --- a/src/Http/Http.Abstractions/src/Authentication/AuthenticationDescription.cs +++ /dev/null @@ -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 -{ - /// - /// Contains information describing an authentication provider. - /// - public class AuthenticationDescription - { - private const string DisplayNamePropertyKey = "DisplayName"; - private const string AuthenticationSchemePropertyKey = "AuthenticationScheme"; - - /// - /// Initializes a new instance of the class - /// - public AuthenticationDescription() - : this(items: null) - { - } - - /// - /// Initializes a new instance of the class - /// - /// - public AuthenticationDescription(IDictionary items) - { - Items = items ?? new Dictionary(StringComparer.Ordinal); ; - } - - /// - /// Contains metadata about the authentication provider. - /// - public IDictionary Items { get; } - - /// - /// Gets or sets the name used to reference the authentication middleware instance. - /// - public string AuthenticationScheme - { - get { return GetString(AuthenticationSchemePropertyKey); } - set { Items[AuthenticationSchemePropertyKey] = value; } - } - - /// - /// Gets or sets the display name for the authentication provider. - /// - 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; - } - } -} diff --git a/src/Http/Http.Abstractions/src/Authentication/AuthenticationManager.cs b/src/Http/Http.Abstractions/src/Authentication/AuthenticationManager.cs deleted file mode 100644 index b2916522a5e3..000000000000 --- a/src/Http/Http.Abstractions/src/Authentication/AuthenticationManager.cs +++ /dev/null @@ -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 - { - /// - /// Constant used to represent the automatic scheme - /// - public const string AutomaticScheme = "Automatic"; - - public abstract HttpContext HttpContext { get; } - - public abstract IEnumerable GetAuthenticationSchemes(); - - public abstract Task GetAuthenticateInfoAsync(string authenticationScheme); - - // Will remove once callees have been updated - public abstract Task AuthenticateAsync(AuthenticateContext context); - - public virtual async Task 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); - } - - /// - /// Creates a challenge for the authentication manager with . - /// - /// A that represents the asynchronous challenge operation. - 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); - } - - /// - /// Creates a challenge for the authentication manager with . - /// - /// Additional arbitrary values which may be used by particular authentication types. - /// A that represents the asynchronous challenge operation. - 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); - } -} diff --git a/src/Http/Http.Abstractions/src/Authentication/AuthenticationProperties.cs b/src/Http/Http.Abstractions/src/Authentication/AuthenticationProperties.cs deleted file mode 100644 index 881b24fff5e7..000000000000 --- a/src/Http/Http.Abstractions/src/Authentication/AuthenticationProperties.cs +++ /dev/null @@ -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 -{ - /// - /// Dictionary used to store state values about the authentication session. - /// - 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"; - - /// - /// Initializes a new instance of the class - /// - public AuthenticationProperties() - : this(items: null) - { - } - - /// - /// Initializes a new instance of the class - /// - /// - public AuthenticationProperties(IDictionary items) - { - Items = items ?? new Dictionary(StringComparer.Ordinal); - } - - /// - /// State values about the authentication session. - /// - public IDictionary Items { get; } - - /// - /// Gets or sets whether the authentication session is persisted across multiple requests. - /// - 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); - } - } - } - } - - /// - /// Gets or sets the full path or absolute URI to be used as an HTTP redirect response value. - /// - 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); - } - } - } - } - - /// - /// Gets or sets the time at which the authentication ticket was issued. - /// - 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); - } - } - } - } - - /// - /// Gets or sets the time at which the authentication ticket expires. - /// - 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); - } - } - } - } - - /// - /// Gets or sets if refreshing the authentication session should be allowed. - /// - 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); - } - } - } - } - } -} diff --git a/src/Http/Http.Abstractions/src/HttpContext.cs b/src/Http/Http.Abstractions/src/HttpContext.cs index c5416cc0b95b..115e8a810ded 100644 --- a/src/Http/Http.Abstractions/src/HttpContext.cs +++ b/src/Http/Http.Abstractions/src/HttpContext.cs @@ -5,7 +5,6 @@ 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 diff --git a/src/Http/Http.Abstractions/src/breakingchanges.netcore.json b/src/Http/Http.Abstractions/src/breakingchanges.netcore.json new file mode 100644 index 000000000000..fa7e1e10f126 --- /dev/null +++ b/src/Http/Http.Abstractions/src/breakingchanges.netcore.json @@ -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" + } + ] \ No newline at end of file diff --git a/src/Http/Http.Features/src/Authentication/AuthenticateContext.cs b/src/Http/Http.Features/src/Authentication/AuthenticateContext.cs deleted file mode 100644 index e73061667b4a..000000000000 --- a/src/Http/Http.Features/src/Authentication/AuthenticateContext.cs +++ /dev/null @@ -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 Properties { get; private set; } - - public IDictionary Description { get; private set; } - - public Exception Error { get; private set; } - - public virtual void Authenticated(ClaimsPrincipal principal, IDictionary properties, IDictionary 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; - } - } -} diff --git a/src/Http/Http.Features/src/Authentication/ChallengeBehavior.cs b/src/Http/Http.Features/src/Authentication/ChallengeBehavior.cs deleted file mode 100644 index 549d51132a70..000000000000 --- a/src/Http/Http.Features/src/Authentication/ChallengeBehavior.cs +++ /dev/null @@ -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 - } -} \ No newline at end of file diff --git a/src/Http/Http.Features/src/Authentication/ChallengeContext.cs b/src/Http/Http.Features/src/Authentication/ChallengeContext.cs deleted file mode 100644 index c0fe470806aa..000000000000 --- a/src/Http/Http.Features/src/Authentication/ChallengeContext.cs +++ /dev/null @@ -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 properties, ChallengeBehavior behavior) - { - if (string.IsNullOrEmpty(authenticationScheme)) - { - throw new ArgumentException(nameof(authenticationScheme)); - } - - AuthenticationScheme = authenticationScheme; - Properties = properties ?? new Dictionary(StringComparer.Ordinal); - Behavior = behavior; - } - - public string AuthenticationScheme { get; } - - public ChallengeBehavior Behavior { get; } - - public IDictionary Properties { get; } - - public bool Accepted { get; private set; } - - public void Accept() - { - Accepted = true; - } - } -} \ No newline at end of file diff --git a/src/Http/Http.Features/src/Authentication/DescribeSchemesContext.cs b/src/Http/Http.Features/src/Authentication/DescribeSchemesContext.cs deleted file mode 100644 index b25c2c979ac0..000000000000 --- a/src/Http/Http.Features/src/Authentication/DescribeSchemesContext.cs +++ /dev/null @@ -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> _results; - - public DescribeSchemesContext() - { - _results = new List>(); - } - - public IEnumerable> Results - { - get { return _results; } - } - - public void Accept(IDictionary description) - { - _results.Add(description); - } - } -} \ No newline at end of file diff --git a/src/Http/Http.Features/src/Authentication/IAuthenticationHandler.cs b/src/Http/Http.Features/src/Authentication/IAuthenticationHandler.cs deleted file mode 100644 index 3b7236418290..000000000000 --- a/src/Http/Http.Features/src/Authentication/IAuthenticationHandler.cs +++ /dev/null @@ -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); - } -} diff --git a/src/Http/Http.Features/src/Authentication/IHttpAuthenticationFeature.cs b/src/Http/Http.Features/src/Authentication/IHttpAuthenticationFeature.cs index 279d6904f08a..49684c0df7c9 100644 --- a/src/Http/Http.Features/src/Authentication/IHttpAuthenticationFeature.cs +++ b/src/Http/Http.Features/src/Authentication/IHttpAuthenticationFeature.cs @@ -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; } } -} \ No newline at end of file +} diff --git a/src/Http/Http.Features/src/Authentication/SignInContext.cs b/src/Http/Http.Features/src/Authentication/SignInContext.cs deleted file mode 100644 index f04dade51b99..000000000000 --- a/src/Http/Http.Features/src/Authentication/SignInContext.cs +++ /dev/null @@ -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 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(StringComparer.Ordinal); - } - - public string AuthenticationScheme { get; } - - public ClaimsPrincipal Principal { get; } - - public IDictionary Properties { get; } - - public bool Accepted { get; private set; } - - public void Accept() - { - Accepted = true; - } - } -} \ No newline at end of file diff --git a/src/Http/Http.Features/src/Authentication/SignOutContext.cs b/src/Http/Http.Features/src/Authentication/SignOutContext.cs deleted file mode 100644 index c752f057dfe0..000000000000 --- a/src/Http/Http.Features/src/Authentication/SignOutContext.cs +++ /dev/null @@ -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 properties) - { - if (string.IsNullOrEmpty(authenticationScheme)) - { - throw new ArgumentException(nameof(authenticationScheme)); - } - - AuthenticationScheme = authenticationScheme; - Properties = properties ?? new Dictionary(StringComparer.Ordinal); - } - - public string AuthenticationScheme { get; } - - public IDictionary Properties { get; } - - public bool Accepted { get; private set; } - - public void Accept() - { - Accepted = true; - } - } -} \ No newline at end of file diff --git a/src/Http/Http.Features/src/breakingchanges.netcore.json b/src/Http/Http.Features/src/breakingchanges.netcore.json new file mode 100644 index 000000000000..2e54d9c1394e --- /dev/null +++ b/src/Http/Http.Features/src/breakingchanges.netcore.json @@ -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" + } + ] \ No newline at end of file diff --git a/src/Http/Http.Features/test/Authentication/AuthenticateContextTest.cs b/src/Http/Http.Features/test/Authentication/AuthenticateContextTest.cs deleted file mode 100644 index c4d901322e58..000000000000 --- a/src/Http/Http.Features/test/Authentication/AuthenticateContextTest.cs +++ /dev/null @@ -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(); - var description = new Dictionary(); - - // 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(); - var description = new Dictionary(); - - 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(), new Dictionary()); - - // 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(), new Dictionary()); - - // 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); - } - } -} diff --git a/src/Http/Http/src/DefaultHttpContext.cs b/src/Http/Http/src/DefaultHttpContext.cs index 7a03c7a3acd6..0884da382376 100644 --- a/src/Http/Http/src/DefaultHttpContext.cs +++ b/src/Http/Http/src/DefaultHttpContext.cs @@ -94,7 +94,6 @@ public void Uninitialize() public override WebSocketManager WebSockets => _websockets ?? (_websockets = new DefaultWebSocketManager(_features.Collection)); - public override ClaimsPrincipal User { get diff --git a/src/Http/Http/src/Features/Authentication/HttpAuthenticationFeature.cs b/src/Http/Http/src/Features/Authentication/HttpAuthenticationFeature.cs index 9a14b657121b..b2ba477f8600 100644 --- a/src/Http/Http/src/Features/Authentication/HttpAuthenticationFeature.cs +++ b/src/Http/Http/src/Features/Authentication/HttpAuthenticationFeature.cs @@ -12,11 +12,5 @@ public ClaimsPrincipal User get; set; } - - public IAuthenticationHandler Handler - { - get; - set; - } } } diff --git a/src/Http/Http/src/breakingchanges.netcore.json b/src/Http/Http/src/breakingchanges.netcore.json new file mode 100644 index 000000000000..269ffeb11967 --- /dev/null +++ b/src/Http/Http/src/breakingchanges.netcore.json @@ -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" + } + ] \ No newline at end of file diff --git a/src/Http/Owin/src/OwinFeatureCollection.cs b/src/Http/Owin/src/OwinFeatureCollection.cs index 4838b99f5cd0..880bd0d0c7d1 100644 --- a/src/Http/Owin/src/OwinFeatureCollection.cs +++ b/src/Http/Owin/src/OwinFeatureCollection.cs @@ -279,8 +279,6 @@ ClaimsPrincipal IHttpAuthenticationFeature.User } } - IAuthenticationHandler IHttpAuthenticationFeature.Handler { get; set; } - /// /// Gets or sets if the underlying server supports WebSockets. This is enabled by default. /// The value should be consistent across requests. diff --git a/src/Identity/Core/src/ISecurityStampValidator.cs b/src/Identity/Core/src/ISecurityStampValidator.cs index f24b76a6ee53..72bc3adceda3 100644 --- a/src/Identity/Core/src/ISecurityStampValidator.cs +++ b/src/Identity/Core/src/ISecurityStampValidator.cs @@ -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 @@ public interface ISecurityStampValidator /// the identity. /// /// The context containing the - /// and to validate. + /// and to validate. /// The that represents the asynchronous validation operation. Task ValidateAsync(CookieValidatePrincipalContext context); } diff --git a/src/Identity/Core/src/SecurityStampValidator.cs b/src/Identity/Core/src/SecurityStampValidator.cs index 9a9ecbe139be..1766d1b45099 100644 --- a/src/Identity/Core/src/SecurityStampValidator.cs +++ b/src/Identity/Core/src/SecurityStampValidator.cs @@ -94,7 +94,7 @@ protected virtual Task VerifySecurityStamp(ClaimsPrincipal principal) /// the identity. /// /// The context containing the - /// and to validate. + /// and to validate. /// The that represents the asynchronous validation operation. public virtual async Task ValidateAsync(CookieValidatePrincipalContext context) { diff --git a/src/Security/Authentication/Core/src/PropertiesDataFormat.cs b/src/Security/Authentication/Core/src/PropertiesDataFormat.cs index 3d31e4bd2d03..cb35d39dee5f 100644 --- a/src/Security/Authentication/Core/src/PropertiesDataFormat.cs +++ b/src/Security/Authentication/Core/src/PropertiesDataFormat.cs @@ -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 { diff --git a/src/Security/Authentication/Core/src/PropertiesSerializer.cs b/src/Security/Authentication/Core/src/PropertiesSerializer.cs index dd30b45ae032..c213bc4f6056 100644 --- a/src/Security/Authentication/Core/src/PropertiesSerializer.cs +++ b/src/Security/Authentication/Core/src/PropertiesSerializer.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication { diff --git a/src/Security/Authentication/Core/src/RemoteAuthenticationOptions.cs b/src/Security/Authentication/Core/src/RemoteAuthenticationOptions.cs index 188b7a9917ed..a84334806724 100644 --- a/src/Security/Authentication/Core/src/RemoteAuthenticationOptions.cs +++ b/src/Security/Authentication/Core/src/RemoteAuthenticationOptions.cs @@ -126,7 +126,7 @@ public override void Validate() /// /// Defines whether access and refresh tokens should be stored in the - /// after a successful authorization. + /// after a successful authorization. /// This property is set to false by default to reduce /// the size of the final authentication cookie. /// diff --git a/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs b/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs index 976ddc581eed..f0e7cbc5dee5 100644 --- a/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs +++ b/src/Security/Authentication/JwtBearer/src/JwtBearerOptions.cs @@ -101,7 +101,7 @@ public class JwtBearerOptions : AuthenticationSchemeOptions /// /// Defines whether the bearer token should be stored in the - /// after a successful authorization. + /// after a successful authorization. /// public bool SaveToken { get; set; } = true; diff --git a/src/Security/Authentication/Twitter/src/Messages/RequestToken.cs b/src/Security/Authentication/Twitter/src/Messages/RequestToken.cs index 04c334e3d384..f6bd2dc29b5b 100644 --- a/src/Security/Authentication/Twitter/src/Messages/RequestToken.cs +++ b/src/Security/Authentication/Twitter/src/Messages/RequestToken.cs @@ -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 { /// diff --git a/src/Security/Authentication/Twitter/src/Messages/RequestTokenSerializer.cs b/src/Security/Authentication/Twitter/src/Messages/RequestTokenSerializer.cs index 88b10d3d60ef..f91a80ba2096 100644 --- a/src/Security/Authentication/Twitter/src/Messages/RequestTokenSerializer.cs +++ b/src/Security/Authentication/Twitter/src/Messages/RequestTokenSerializer.cs @@ -3,7 +3,6 @@ using System; using System.IO; -using Microsoft.AspNetCore.Http.Authentication; namespace Microsoft.AspNetCore.Authentication.Twitter { diff --git a/src/Security/Authentication/Twitter/src/TwitterEvents.cs b/src/Security/Authentication/Twitter/src/TwitterEvents.cs index 744c48c5fc0e..ef5e864edaec 100644 --- a/src/Security/Authentication/Twitter/src/TwitterEvents.cs +++ b/src/Security/Authentication/Twitter/src/TwitterEvents.cs @@ -35,7 +35,7 @@ public class TwitterEvents : RemoteAuthenticationEvents /// /// Called when a Challenge causes a redirect to authorize endpoint in the Twitter handler /// - /// Contains redirect URI and of the challenge + /// Contains redirect URI and of the challenge public virtual Task RedirectToAuthorizationEndpoint(RedirectContext context) => OnRedirectToAuthorizationEndpoint(context); } } diff --git a/src/Servers/HttpSys/src/FeatureContext.cs b/src/Servers/HttpSys/src/FeatureContext.cs index 193b87f96960..27a38a84d8f7 100644 --- a/src/Servers/HttpSys/src/FeatureContext.cs +++ b/src/Servers/HttpSys/src/FeatureContext.cs @@ -450,8 +450,6 @@ ClaimsPrincipal IHttpAuthenticationFeature.User set { _user = value; } } - IAuthenticationHandler IHttpAuthenticationFeature.Handler { get; set; } - string IHttpRequestIdentifierFeature.TraceIdentifier { get diff --git a/src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs b/src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs index 6e1656a4876e..b2e39fccd7f6 100644 --- a/src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs +++ b/src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs @@ -195,8 +195,6 @@ ClaimsPrincipal IHttpAuthenticationFeature.User set => User = value; } - public IAuthenticationHandler Handler { get; set; } - string IServerVariablesFeature.this[string variableName] { get