dotnet / dotnet/SqlClient

Add support for MSAL Token Cache persistence with Azure authentication

Open
#1,895 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
989
Forks
340
Avg merge
4d 19h
Merged PRs (30d)
72

Description

Presently, [ActiveDirectoryAuthenticationProvider](https://github.com/dotnet/SqlClient/blob/20d4c199923c9b4ea2ffd44d9304fcb306c5efb5/src/Microsoft.Data.SqlClient/src/Microsoft/Data/SqlClient/ActiveDirectoryAuthenticationProvider.cs#L18) implements all authentication modes but MSAL Cache location is not customizable and is in-memory by default. Cache persistence is useful for system apps that want to cache access token to file system using MSAL/Azure.Identity's cache options.

### Proposed solution:
Expose API/type to enable cache persistence in OS with user options, such as:
- Cache file name
- Cache file location
- Cache encryption (enabled/disabled)
- Cache Key format
and so on..

These options can be extended based on what underlying libraries support, and most common options can be supported. Because underlying libraries are not same for all auth modes, exposing a SqlClient specific API will ensure this support continues to be available across all authentication modes that support silent authentication.

### Alternatives
The only alternative solution as of now is to implement the [SqlAuthenticationProvider](https://learn.microsoft.com/en-us/dotnet/api/microsoft.data.sqlclient.sqlauthenticationprovider?view=sqlclient-dotnet-standard-5.0) abstract class to be able to customize cache location and enable persistence.

I still need to solidify API design proposal but putting out this feature request to exchange thoughts :)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.