dotnet / AspNetCore.Docs

Documentation for ASP.NET Core
https://docs.microsoft.com/aspnet/core
Creative Commons Attribution 4.0 International
12.54k stars 25.31k forks source link

Microsoft.AspNetCore.Authentication deprecated #29655

Open ebiton-eig opened 1 year ago

ebiton-eig commented 1 year ago

The nuget package Microsoft.AspNetCore.Authentication is deprecated (.NET Core 2)

How can I do the same thing in .NET 7 in a library (not an app) without this package?


Document Details

Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.

JeremyLikness commented 1 year ago

Hi @ebiton-eig,

I assume it's the .NET Core 2 package that's deprecated, not the library itself. You should be able to include the same package (the newer version that targets ASP.NET Core on .NET 7) in your library projects:

https://www.nuget.org/packages/Microsoft.AspNetCore.Authorization

Regards,

Jeremy

ebiton-eig commented 1 year ago

Hi!

No, you're confusing Microsoft.AspNetCore.Authentication with Microsoft.AspNetCore.Authorization. The first one simply no longer exists, and was the one that contained AuthenticationHandler, for example.

Regards.

JeremyLikness commented 1 year ago

Good point. What are you trying to accomplish? We have separate libs for things like managing JWT tokens, managing identity either externally handled (i.e. Azure) or locally via ASP.NET Core Identity. Can you provide a bit more context?

ebiton-eig commented 1 year ago

We use a custom scheme to verify authentication between microservices (no-trust). This system is not based on a standard such as JWT or OAuth2.

guardrex commented 1 year ago

@ebiton-eig ... See :point_right: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-7.0&tabs=visual-studio#use-the-aspnet-core-shared-framework

Give your lib access to the shared framework using that guidance, and you should be good for using that assembly's API.

@Rick-Anderson ... I'll leave this open in case you had something in mind for work. I'm going to add something to the Blazor class libs article on this, probably just an additional resource cross-link. I'm going to track that on my Blazor tracking issue. I won't be working it off of this issue. In case you need it, the cross-link is <xref:fundamentals/target-aspnetcore>.