diff --git a/src/Microsoft.AspNetCore.Http.Features/Authentication/IHttpAuthenticationFeature.cs b/src/Microsoft.AspNetCore.Http.Features/Authentication/IHttpAuthenticationFeature.cs index 080ce405..279d6904 100644 --- a/src/Microsoft.AspNetCore.Http.Features/Authentication/IHttpAuthenticationFeature.cs +++ b/src/Microsoft.AspNetCore.Http.Features/Authentication/IHttpAuthenticationFeature.cs @@ -1,6 +1,7 @@ // 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.Features.Authentication @@ -9,6 +10,7 @@ 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/Microsoft.AspNetCore.Http/Authentication/DefaultAuthenticationManager.cs b/src/Microsoft.AspNetCore.Http/Authentication/DefaultAuthenticationManager.cs index 666e2179..a6cc320b 100644 --- a/src/Microsoft.AspNetCore.Http/Authentication/DefaultAuthenticationManager.cs +++ b/src/Microsoft.AspNetCore.Http/Authentication/DefaultAuthenticationManager.cs @@ -42,7 +42,9 @@ public virtual void Uninitialize() public override IEnumerable GetAuthenticationSchemes() { +#pragma warning disable CS0618 // Type or member is obsolete var handler = HttpAuthenticationFeature.Handler; +#pragma warning restore CS0618 // Type or member is obsolete if (handler == null) { return new AuthenticationDescription[0]; @@ -61,7 +63,9 @@ public override async Task AuthenticateAsync(AuthenticateContext context) throw new ArgumentNullException(nameof(context)); } +#pragma warning disable CS0618 // Type or member is obsolete var handler = HttpAuthenticationFeature.Handler; +#pragma warning restore CS0618 // Type or member is obsolete if (handler != null) { await handler.AuthenticateAsync(context); @@ -80,7 +84,9 @@ public override async Task GetAuthenticateInfoAsync(string aut throw new ArgumentNullException(nameof(authenticationScheme)); } +#pragma warning disable CS0618 // Type or member is obsolete var handler = HttpAuthenticationFeature.Handler; +#pragma warning restore CS0618 // Type or member is obsolete var context = new AuthenticateContext(authenticationScheme); if (handler != null) { @@ -107,7 +113,9 @@ public override async Task ChallengeAsync(string authenticationScheme, Authentic throw new ArgumentException(nameof(authenticationScheme)); } +#pragma warning disable CS0618 // Type or member is obsolete var handler = HttpAuthenticationFeature.Handler; +#pragma warning restore CS0618 // Type or member is obsolete var challengeContext = new ChallengeContext(authenticationScheme, properties?.Items, behavior); if (handler != null) @@ -133,7 +141,9 @@ public override async Task SignInAsync(string authenticationScheme, ClaimsPrinci throw new ArgumentNullException(nameof(principal)); } +#pragma warning disable CS0618 // Type or member is obsolete var handler = HttpAuthenticationFeature.Handler; +#pragma warning restore CS0618 // Type or member is obsolete var signInContext = new SignInContext(authenticationScheme, principal, properties?.Items); if (handler != null) @@ -154,7 +164,9 @@ public override async Task SignOutAsync(string authenticationScheme, Authenticat throw new ArgumentException(nameof(authenticationScheme)); } +#pragma warning disable CS0618 // Type or member is obsolete var handler = HttpAuthenticationFeature.Handler; +#pragma warning restore CS0618 // Type or member is obsolete var signOutContext = new SignOutContext(authenticationScheme, properties?.Items); if (handler != null)