Skip to content

Commit

Permalink
Add ISession provider.
Browse files Browse the repository at this point in the history
  • Loading branch information
pmaytak committed Jul 11, 2020
1 parent 7cfc0cb commit 2f133d1
Showing 1 changed file with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
using System.Linq;
using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.DependencyInjection.Extensions;

namespace Microsoft.Identity.Web.TokenCacheProviders.Session
{
Expand Down Expand Up @@ -64,6 +66,7 @@ public static IServiceCollection AddSessionTokenCaches(this IServiceCollection s

services.AddHttpContextAccessor();
services.AddScoped<IMsalTokenCacheProvider, MsalSessionTokenCacheProvider>();
services.TryAddScoped(provider => provider.GetService<IHttpContextAccessor>().HttpContext.Session);

return services;
}
Expand Down Expand Up @@ -129,7 +132,13 @@ public static IServiceCollection AddSessionAppTokenCache(this IServiceCollection
}

services.AddHttpContextAccessor();
services.AddSession(option =>
{
option.Cookie.IsEssential = true;
});
services.AddScoped<IMsalTokenCacheProvider, MsalSessionTokenCacheProvider>();
services.TryAddScoped(provider => provider.GetService<IHttpContextAccessor>().HttpContext.Session);

return services;
}

Expand Down Expand Up @@ -167,6 +176,8 @@ public static IServiceCollection AddSessionPerUserTokenCache(this IServiceCollec
option.Cookie.IsEssential = true;
});
services.AddScoped<IMsalTokenCacheProvider, MsalSessionTokenCacheProvider>();
services.TryAddScoped(provider => provider.GetService<IHttpContextAccessor>().HttpContext.Session);

return services;
}
}
Expand Down

0 comments on commit 2f133d1

Please sign in to comment.