Skip to content

Added helper methods #70

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

Merged
merged 1 commit into from
Mar 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ namespace Microsoft.Identity.Web.Client.TokenCacheProviders
{
public static class MSALAppMemoryTokenCacheProviderExtension
{
/// <summary>Adds both the app and per-user in-memory token caches.</summary>
/// <param name="services">The services collection to add to.</param>
/// <param name="cacheOptions">the MSALMemoryTokenCacheOptions allows the caller to set the token cache expiration</param>
/// <returns></returns>
public static IServiceCollection AddInMemoryTokenCaches(this IServiceCollection services, MSALMemoryTokenCacheOptions cacheOptions = null)
{
var memoryCacheoptions = (cacheOptions == null) ? new MSALMemoryTokenCacheOptions { AbsoluteExpiration = DateTimeOffset.Now.AddDays(14) }
Expand All @@ -43,9 +47,9 @@ public static IServiceCollection AddInMemoryTokenCaches(this IServiceCollection
}


/// <summary>Adds the in memory based application token cache to the service collection.</summary>
/// <summary>Adds the in-memory based application token cache to the service collection.</summary>
/// <param name="services">The services collection to add to.</param>
/// <param name="cacheOptions"></param>
/// <param name="cacheOptions">the MSALMemoryTokenCacheOptions allows the caller to set the token cache expiration</param>
public static IServiceCollection AddInMemoryAppTokenCache(this IServiceCollection services, MSALMemoryTokenCacheOptions cacheOptions)
{
services.AddMemoryCache();
Expand All @@ -61,8 +65,9 @@ public static IServiceCollection AddInMemoryAppTokenCache(this IServiceCollectio
return services;
}

/// <summary>Adds the in memory based per user token cache to the service collection.</summary>
/// <summary>Adds the in-memory based per user token cache to the service collection.</summary>
/// <param name="services">The services collection to add to.</param>
/// <param name="cacheOptions">the MSALMemoryTokenCacheOptions allows the caller to set the token cache expiration</param>
/// <returns></returns>
public static IServiceCollection AddInMemoryPerUserTokenCache(this IServiceCollection services, MSALMemoryTokenCacheOptions cacheOptions)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,9 @@ public class MSALAppSessionTokenCacheProvider : IMSALAppTokenCacheProvider
/// </summary>
private string AppId;

/// <summary>Initializes a new instance of the <see cref="MSALAppSessionTokenCacheProvider"/> class.</summary>
/// <param name="azureAdOptionsAccessor">The azure ad options accessor.</param>
/// <exception cref="ArgumentNullException">AzureADOptions - The app token cache needs {nameof(AzureADOptions)}</exception>
public MSALAppSessionTokenCacheProvider(IOptionsMonitor<AzureADOptions> azureAdOptionsAccessor)
{
if (azureAdOptionsAccessor.CurrentValue == null && string.IsNullOrWhiteSpace(azureAdOptionsAccessor.CurrentValue.ClientId))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,17 @@ namespace Microsoft.Identity.Web.Client.TokenCacheProviders
{
public static class MSALAppSessionTokenCacheProviderExtension
{
/// <summary>Adds both App and per-user session token caches.</summary>
/// <param name="services">The services collection to add to.</param>
/// <returns></returns>
public static IServiceCollection AddSessionTokenCaches(this IServiceCollection services)
{
AddSessionAppTokenCache(services);
AddSessionPerUserTokenCache(services);

return services;
}

/// <summary>Adds the Http session based application token cache to the service collection.</summary>
/// <param name="services">The services collection to add to.</param>
/// <returns></returns>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,20 @@ namespace Microsoft.Identity.Web.Client.TokenCacheProviders
{
public static class MSALAppSqlTokenCacheProviderExtension
{
/// <summary>
/// Adds the Sql Server based application token cache to the service collection.
/// </summary>
/// <param name="services">The services collection to add to.</param>
/// <summary>Adds the app and per user SQL token caches.</summary>
/// <param name="configuration">The configuration instance from where this method pulls the connection string to the Sql database.</param>
/// <param name="sqlTokenCacheOptions">The MSALSqlTokenCacheOptions is used by the caller to specify the Sql connection string</param>
/// <returns></returns>
public static IServiceCollection AddSqlTokenCaches(this IServiceCollection services, MSALSqlTokenCacheOptions sqlTokenCacheOptions)
{
AddSqlAppTokenCache(services, sqlTokenCacheOptions);
AddSqlPerUserTokenCache(services, sqlTokenCacheOptions);
return services;
}

/// <summary>Adds the Sql Server based application token cache to the service collection.</summary>
/// <param name="services">The services collection to add to.</param>
/// <param name="sqlTokenCacheOptions">The MSALSqlTokenCacheOptions is used by the caller to specify the Sql connection string</param>
/// <returns></returns>
public static IServiceCollection AddSqlAppTokenCache(this IServiceCollection services, MSALSqlTokenCacheOptions sqlTokenCacheOptions)
{
Expand Down Expand Up @@ -66,8 +75,8 @@ public static IServiceCollection AddSqlAppTokenCache(this IServiceCollection ser
}

/// <summary>Adds the Sql Server based per user token cache to the service collection.</summary>
/// <param name="services">The services.</param>
/// <param name="configuration">The configuration instance from where this method pulls the connection string to the Sql database.</param>
/// <param name="services">The services collection to add to.</param>
/// <param name="sqlTokenCacheOptions">The MSALSqlTokenCacheOptions is used by the caller to specify the Sql connection string</param>
/// <returns></returns>
public static IServiceCollection AddSqlPerUserTokenCache(this IServiceCollection services, MSALSqlTokenCacheOptions sqlTokenCacheOptions)
{
Expand Down