Skip to content
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

Not working with AOT #45

Open
miawinter98 opened this issue Jun 21, 2024 · 0 comments
Open

Not working with AOT #45

miawinter98 opened this issue Jun 21, 2024 · 0 comments

Comments

@miawinter98
Copy link

During compilation the following warning is generated: /root/.nuget/packages/aspnetcore.authentication.apikey/8.0.1/lib/net8.0/AspNetCore.Authentication.ApiKey.dll : warning IL2104: Assembly 'AspNetCore.Authentication.ApiKey' produced trim warnings. For more information see https://aka.ms/dotnet-illink/libraries

And during runtime, when a challenge occurs, this error is logged: System.InvalidOperationException: A suitable constructor for type 'AspNetCore.Authentication.ApiKey.ApiKeyInHeaderHandler' could not be located. Ensure the type is concrete and services are registered for all parameters of a public constructor.

This happens both when implementing IApiKeyProvider as well as when adding OnValidateKey on ApiKeyEvents in ApiKeyOptions.Events

It seems something is happening with AspNetCore.Authentication.ApiKey.ApiKeyInHeaderHandler during trimming, as the type itself is found but not a (fitting) constructor.
At this time, I do not know enough about how AOT works to pinpoint what exactly is causing these problems, however, the documentation about Asp.Net' AOT support notes that only JWT Authentication is fully supported, so it seems to be not uncommon for auth schemes to require extra work to function.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant