Skip to content
This repository was archived by the owner on Oct 18, 2018. It is now read-only.

Commit 30897e0

Browse files
committed
Remove max length restrictions on secret keys
- #245 nits: - let VS remove BOMs
1 parent c9ab0b4 commit 30897e0

File tree

24 files changed

+20
-116
lines changed

24 files changed

+20
-116
lines changed

src/Microsoft.AspNetCore.WebHooks.Receivers.Dropbox/DropboxConstants.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
namespace Microsoft.AspNetCore.WebHooks
@@ -30,12 +30,6 @@ public static class DropboxConstants
3030
/// </summary>
3131
public static int SecretKeyMinLength => 15;
3232

33-
/// <summary>
34-
/// Gets the maximum length of the secret key configured for this receiver. Used to confirm the secret key is
35-
/// property configured before responding to an HTTP GET request.
36-
/// </summary>
37-
public static int SecretKeyMaxLength => 128;
38-
3933
/// <summary>
4034
/// Gets the name of the HTTP header that contains the (hex-encoded) signature of the request.
4135
/// </summary>

src/Microsoft.AspNetCore.WebHooks.Receivers.Dropbox/Filters/DropboxVerifySignatureFilter.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -82,11 +82,7 @@ public async Task OnResourceExecutionAsync(ResourceExecutingContext context, Res
8282
}
8383

8484
// 3. Get the configured secret key.
85-
var secretKey = GetSecretKey(
86-
ReceiverName,
87-
context.RouteData,
88-
DropboxConstants.SecretKeyMinLength,
89-
DropboxConstants.SecretKeyMaxLength);
85+
var secretKey = GetSecretKey(ReceiverName, context.RouteData, DropboxConstants.SecretKeyMinLength);
9086
if (secretKey == null)
9187
{
9288
context.Result = new NotFoundResult();

src/Microsoft.AspNetCore.WebHooks.Receivers.Dropbox/Metadata/DropboxMetadata.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,6 @@ public DropboxMetadata(DropboxVerifySignatureFilter verifySignatureFilter)
5353
/// <inheritdoc />
5454
public int SecretKeyMinLength => DropboxConstants.SecretKeyMinLength;
5555

56-
/// <inheritdoc />
57-
public int SecretKeyMaxLength => DropboxConstants.SecretKeyMaxLength;
58-
5956
// IWebHookFilterMetadata...
6057

6158
/// <inheritdoc />

src/Microsoft.AspNetCore.WebHooks.Receivers.GitHub/Filters/GitHubVerifySignatureFilter.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,7 @@ public async Task OnResourceExecutionAsync(ResourceExecutingContext context, Res
119119
}
120120

121121
// 3. Get the configured secret key.
122-
var secretKey = GetSecretKey(
123-
ReceiverName,
124-
context.RouteData,
125-
GitHubConstants.SecretKeyMinLength,
126-
GitHubConstants.SecretKeyMaxLength);
122+
var secretKey = GetSecretKey(ReceiverName, context.RouteData, GitHubConstants.SecretKeyMinLength);
127123
if (secretKey == null)
128124
{
129125
context.Result = new NotFoundResult();

src/Microsoft.AspNetCore.WebHooks.Receivers.GitHub/GitHubConstants.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
namespace Microsoft.AspNetCore.WebHooks
@@ -28,11 +28,6 @@ public static class GitHubConstants
2828
/// </summary>
2929
public static int SecretKeyMinLength => 16;
3030

31-
/// <summary>
32-
/// Gets the maximum length of the secret key configured for this receiver.
33-
/// </summary>
34-
public static int SecretKeyMaxLength => 128;
35-
3631
/// <summary>
3732
/// Gets the key of the hex-encoded signature in the <see cref="SignatureHeaderName"/> value.
3833
/// </summary>

src/Microsoft.AspNetCore.WebHooks.Receivers.MailChimp/Metadata/MailChimpMetadata.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,5 @@ public MailChimpMetadata()
4444

4545
/// <inheritdoc />
4646
public int SecretKeyMinLength => WebHookConstants.CodeParameterMinLength;
47-
48-
/// <inheritdoc />
49-
public int SecretKeyMaxLength => WebHookConstants.CodeParameterMaxLength;
5047
}
5148
}

src/Microsoft.AspNetCore.WebHooks.Receivers.Pusher/Filters/PusherVerifySignatureFilter.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,9 +102,7 @@ public async Task OnResourceExecutionAsync(ResourceExecutingContext context, Res
102102
}
103103

104104
var secretKey = secretKeys[applicationKey];
105-
if (secretKey == null ||
106-
secretKey.Length < PusherConstants.SecretKeyMinLength ||
107-
secretKey.Length > PusherConstants.SecretKeyMaxLength)
105+
if (secretKey == null || secretKey.Length < PusherConstants.SecretKeyMinLength)
108106
{
109107
Logger.LogWarning(
110108
0,

src/Microsoft.AspNetCore.WebHooks.Receivers.Pusher/PusherConstants.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
namespace Microsoft.AspNetCore.WebHooks
@@ -48,11 +48,6 @@ public static class PusherConstants
4848
/// </summary>
4949
public static int SecretKeyMinLength => 8;
5050

51-
/// <summary>
52-
/// Gets the maximum length of the secret key configured for this receiver.
53-
/// </summary>
54-
public static int SecretKeyMaxLength => 128;
55-
5651
/// <summary>
5752
/// Gets the name of the HTTP header containing the key into the configured lookup table. Named entry in the
5853
/// table contains the secret key the sender used when generating the <see cref="SignatureHeaderName"/> value.

src/Microsoft.AspNetCore.WebHooks.Receivers.Salesforce/Filters/SalesforceVerifyOrganizationIdFilter.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ public async Task OnResourceExecutionAsync(ResourceExecutingContext context, Res
128128
}
129129

130130
var routeData = context.RouteData;
131-
var secret = GetSecretKey(
132-
ReceiverName,
133-
routeData,
134-
SalesforceConstants.SecretKeyMinLength,
135-
SalesforceConstants.SecretKeyMaxLength);
131+
var secret = GetSecretKey(ReceiverName, routeData, SalesforceConstants.SecretKeyMinLength);
136132

137133
var organizationId = GetShortOrganizationId(organizationIds[0]);
138134
var secretKey = GetShortOrganizationId(secret);

src/Microsoft.AspNetCore.WebHooks.Receivers.Salesforce/SalesforceConstants.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) .NET Foundation. All rights reserved.
1+
// Copyright (c) .NET Foundation. All rights reserved.
22
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
33

44
namespace Microsoft.AspNetCore.WebHooks
@@ -30,10 +30,5 @@ public static class SalesforceConstants
3030
/// Gets the minimum length of the secret key configured for this receiver.
3131
/// </summary>
3232
public static int SecretKeyMinLength => 15;
33-
34-
/// <summary>
35-
/// Gets the maximum length of the secret key configured for this receiver.
36-
/// </summary>
37-
public static int SecretKeyMaxLength => 18;
3833
}
3934
}

0 commit comments

Comments
 (0)