Move Antiforgery implementation details to `.Internal`

- leave `IAntiforgery`, `IAntiforgeryAdditionalDataProvider` and related bits behind
This commit is contained in:
Doug Bunting 2016-02-03 14:42:19 -08:00
parent 48ee352022
commit 705c080d3b
25 changed files with 29 additions and 32 deletions

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
/// <summary>
/// Used as a per request state.

View File

@ -8,7 +8,7 @@ using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class AntiforgeryOptionsSetup : ConfigureOptions<AntiforgeryOptions>
{

View File

@ -5,7 +5,7 @@ using System.IO;
using System.Security.Cryptography;
using System.Text;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class AntiforgerySerializationContext
{

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public sealed class AntiforgeryToken
{

View File

@ -8,7 +8,7 @@ using System.Runtime.CompilerServices;
using System.Security.Cryptography;
using System.Text;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
// Represents a binary blob (token) that contains random data.
// Useful for binary data inside a serialized stream.

View File

@ -10,7 +10,7 @@ using Microsoft.AspNetCore.Html;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Options;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
/// <summary>
/// Provides access to the antiforgery system, which provides protection against

View File

@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
/// <summary>
/// A default <see cref="IAntiforgeryAdditionalDataProvider"/> implementation.

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryContextAccessor : IAntiforgeryContextAccessor
{

View File

@ -6,7 +6,7 @@ using System.Security.Claims;
using System.Security.Principal;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTokenGenerator : IAntiforgeryTokenGenerator
{

View File

@ -7,7 +7,7 @@ using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.WebUtilities;
using Microsoft.Extensions.ObjectPool;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTokenSerializer : IAntiforgeryTokenSerializer
{

View File

@ -9,7 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTokenStore : IAntiforgeryTokenStore
{

View File

@ -7,7 +7,7 @@ using System.Linq;
using System.Security.Claims;
using Microsoft.Extensions.ObjectPool;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
/// <summary>
/// Default implementation of <see cref="IClaimUidExtractor"/>.

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public interface IAntiforgeryContextAccessor
{

View File

@ -3,7 +3,7 @@
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
/// <summary>
/// Generates and validates antiforgery tokens.

View File

@ -1,7 +1,7 @@
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
// Abstracts out the serialization process for an antiforgery token
public interface IAntiforgeryTokenSerializer

View File

@ -4,7 +4,7 @@
using System.Threading.Tasks;
using Microsoft.AspNetCore.Http;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
// Provides an abstraction around how tokens are persisted and retrieved for a request
public interface IAntiforgeryTokenStore

View File

@ -3,7 +3,7 @@
using System.Security.Claims;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
/// <summary>
/// This interface can extract unique identifers for a claims-based identity.

View File

@ -5,7 +5,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class AntiforgeryOptionsSetupTest
{

View File

@ -3,7 +3,7 @@
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class AntiforgeryTokenTest
{

View File

@ -4,7 +4,7 @@
using System;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class BinaryBlobTest
{

View File

@ -13,7 +13,7 @@ using Microsoft.Extensions.WebEncoders.Testing;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTest
{
@ -186,7 +186,7 @@ namespace Microsoft.AspNetCore.Antiforgery
var antiforgery = GetAntiforgery(context);
var encoder = new HtmlTestEncoder();
// Setup so that the null cookie token returned is treated as invalid.
// Setup so that the null cookie token returned is treated as invalid.
context.TokenGenerator
.Setup(o => o.IsCookieTokenValid(null))
.Returns(false);
@ -226,7 +226,7 @@ namespace Microsoft.AspNetCore.Antiforgery
.Setup(o => o.GetCookieToken(context.HttpContext))
.Throws(new Exception("should be swallowed"));
// Setup so that the null cookie token returned is treated as invalid.
// Setup so that the null cookie token returned is treated as invalid.
context.TokenGenerator
.Setup(o => o.IsCookieTokenValid(null))
.Returns(false);

View File

@ -9,7 +9,7 @@ using Microsoft.AspNetCore.Testing;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTokenGeneratorProviderTest
{
@ -190,7 +190,7 @@ namespace Microsoft.AspNetCore.Antiforgery
.Returns("my-username");
httpContext.User = new ClaimsPrincipal(mockIdentity.Object);
var claimUidExtractor = new Mock<IClaimUidExtractor>().Object;
var tokenProvider = new DefaultAntiforgeryTokenGenerator(
@ -325,7 +325,7 @@ namespace Microsoft.AspNetCore.Antiforgery
claimUidExtractor: null,
additionalDataProvider: null);
string expectedMessage =
string expectedMessage =
"Validation of the provided antiforgery token failed. " +
"The cookie token and the request token were swapped.";

View File

@ -4,13 +4,12 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.AspNetCore.Antiforgery.Internal;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.Extensions.ObjectPool;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTokenSerializerTest
{

View File

@ -4,7 +4,6 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Antiforgery.Internal;
using Microsoft.AspNetCore.DataProtection;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Http.Internal;
@ -14,7 +13,7 @@ using Microsoft.Extensions.Primitives;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultAntiforgeryTokenStoreTest
{

View File

@ -4,12 +4,11 @@
using System;
using System.Linq;
using System.Security.Claims;
using Microsoft.AspNetCore.Antiforgery.Internal;
using Microsoft.Extensions.ObjectPool;
using Moq;
using Xunit;
namespace Microsoft.AspNetCore.Antiforgery
namespace Microsoft.AspNetCore.Antiforgery.Internal
{
public class DefaultClaimUidExtractorTest
{