aspnetcore-authentication-apikey
aspnetcore-authentication-apikey copied to clipboard
Nullability - IApiKeyProvider.ProvideAsync should return Task<IApiKey?>
Hello!
Thanks for the library 🙏!
Would you agree that it would be proper that the method declaration (ProvideAsync) in the IApiKeyProvider interface should return nullable value since it is explicitly checked in the handler? That way, no compiler warnings would be present (or escape hatches with !) 😄
@skyflyer when the user is not authenticated by your implementation, it must return
return await Task.FromResult<IApiKey>(null);
Sure, but the compiler will warn, because you're returning null when the interface definition does not define that a return type is nullable. That's all I'm saying. :)
I didn't really understand your question, I understood that you wanted to know how to return the value. Reading better now, I understand and agree that it should be nullable.
Sorry 😄