Support for custom authentication scheme without adding data protection #33779
Labels
area-auth
Includes: Authn, Authz, OAuth, OIDC, Bearer
✔️ Resolution: Answered
Resolved because the question asked by the original author has been answered.
Status: Resolved
If you are building a custom authentication scheme that doesn't need data protection, there is currently no way to add authentication without adding data protection services. This means that at startup, keys are generated and logging is created (if they aren't persisted or encrypted) - when it's completely unnecessary.
This is because inside
Microsoft.Extensions.DependencyInjection.AuthenticationServiceCollectionExtensions
the code looks like this:The call to
AddDataProtection
is added indiscriminately. From a developers point of view this can be worked around by replicating this code and the call toAddDataProtection()
is removed:But I expect this code to break in the future as it's not documented or supported.
As a possible solution maybe a new
boolean
property namedRequiresDataProtection
that defaults totrue
could be added to theAuthenticationOptions
class, and if set tofalse
, Data Protection is not added?The text was updated successfully, but these errors were encountered: