#74 - Clean up data protection provider helper.
This commit is contained in:
parent
2c64ebdbc2
commit
95f19407fc
|
|
@ -13,7 +13,7 @@ namespace CookieSessionSample
|
|||
|
||||
public MemoryCacheSessionStore()
|
||||
{
|
||||
_cache = new MemoryCache();
|
||||
_cache = new MemoryCache(new MemoryCacheOptions());
|
||||
}
|
||||
|
||||
public async Task<string> StoreAsync(AuthenticationTicket ticket)
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@ namespace Microsoft.AspNet.Security.Cookies
|
|||
}
|
||||
if (Options.TicketDataFormat == null)
|
||||
{
|
||||
IDataProtector dataProtector = DataProtectionHelpers.CreateDataProtector(dataProtectionProvider,
|
||||
IDataProtector dataProtector = dataProtectionProvider.CreateDataProtector(
|
||||
typeof(CookieAuthenticationMiddleware).FullName, Options.AuthenticationType, "v1");
|
||||
Options.TicketDataFormat = new TicketDataFormat(dataProtector);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ namespace Microsoft.AspNet.Security.OAuth
|
|||
|
||||
if (Options.StateDataFormat == null)
|
||||
{
|
||||
IDataProtector dataProtector = DataProtectionHelpers.CreateDataProtector(dataProtectionProvider,
|
||||
IDataProtector dataProtector = dataProtectionProvider.CreateDataProtector(
|
||||
this.GetType().FullName, Options.AuthenticationType, "v1");
|
||||
Options.StateDataFormat = new PropertiesDataFormat(dataProtector);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ namespace Microsoft.AspNet.Security.OAuth
|
|||
|
||||
if (Options.AccessTokenFormat == null)
|
||||
{
|
||||
var dataProtector = DataProtectionHelpers.CreateDataProtector(dataProtectionProvider,
|
||||
IDataProtector dataProtector = dataProtectionProvider.CreateDataProtector(
|
||||
this.GetType().FullName, Options.AuthenticationType, "v1");
|
||||
Options.AccessTokenFormat = new TicketDataFormat(dataProtector);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace Microsoft.AspNet.Security.Twitter
|
|||
}
|
||||
if (Options.StateDataFormat == null)
|
||||
{
|
||||
IDataProtector dataProtector = DataProtectionHelpers.CreateDataProtector(dataProtectionProvider,
|
||||
IDataProtector dataProtector = dataProtectionProvider.CreateDataProtector(
|
||||
typeof(TwitterAuthenticationMiddleware).FullName, Options.AuthenticationType, "v1");
|
||||
Options.StateDataFormat = new SecureDataFormat<RequestToken>(
|
||||
Serializers.RequestToken,
|
||||
|
|
|
|||
|
|
@ -1,22 +1,12 @@
|
|||
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.
|
||||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
|
||||
|
||||
|
||||
using System;
|
||||
using Microsoft.AspNet.Http;
|
||||
|
||||
namespace Microsoft.AspNet.Security.DataProtection
|
||||
{
|
||||
public static class DataProtectionHelpers
|
||||
{
|
||||
public static IDataProtector CreateDataProtector(IDataProtectionProvider dataProtectionProvider, params string[] purposes)
|
||||
public static IDataProtector CreateDataProtector([NotNull] this IDataProtectionProvider dataProtectionProvider, params string[] purposes)
|
||||
{
|
||||
if (dataProtectionProvider == null)
|
||||
{
|
||||
// TODO: Get this from the environment.
|
||||
dataProtectionProvider = new EphemeralDataProtectionProvider();
|
||||
}
|
||||
|
||||
return dataProtectionProvider.CreateProtector(string.Join(";", purposes));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue