Skip to content

Commit

Permalink
[INTERNAL] Line endings: Adds gitattribute to normalize line endings (#…
Browse files Browse the repository at this point in the history
…3062)

Several of the files have mixed line endings causing issues with PRs saying they changed the entire file instead of just 1 line. This is adding a gitattribute file that will force all the files to use the CRLF formatting. This also fixes all the .cs files to use the correct formatting.
  • Loading branch information
j82w authored Mar 3, 2022
1 parent 63b0e07 commit af9b009
Show file tree
Hide file tree
Showing 47 changed files with 17,142 additions and 17,123 deletions.
19 changes: 19 additions & 0 deletions .gitattribute
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Declare files that will always have CRLF line endings on checkout
* text=auto

*.bmp binary
*.dll binary
*.gif binary
*.jpg binary
*.png binary
*.snk binary
*.exe binary
*.wmv binary
*.mp4 binary
*.ismv binary
*.isma binary

*.cs text diff=csharp eol=crlf
*.csproj text=auto
*.sln text=auto eol=crlf
*.sh text=auto eol=lf
532 changes: 266 additions & 266 deletions Microsoft.Azure.Cosmos.Samples/Tools/Benchmark/BenchmarkConfig.cs

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions Microsoft.Azure.Cosmos/src/Authorization/AuthorizationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ internal static class AuthorizationHelper
{
public const int MaxAuthorizationHeaderSize = 1024;
public const int DefaultAllowedClockSkewInSeconds = 900;
public const int DefaultMasterTokenExpiryInSeconds = 900;
private const int MaxAadAuthorizationHeaderSize = 16 * 1024;
public const int DefaultMasterTokenExpiryInSeconds = 900;
private const int MaxAadAuthorizationHeaderSize = 16 * 1024;
private const int MaxResourceTokenAuthorizationHeaderSize = 8 * 1024;
private static readonly string AuthorizationFormatPrefixUrlEncoded = HttpUtility.UrlEncode(string.Format(CultureInfo.InvariantCulture, Constants.Properties.AuthorizationFormat,
Constants.Properties.MasterToken,
Expand Down Expand Up @@ -253,28 +253,28 @@ public static void ParseAuthorizationToken(
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat);
}

ReadOnlyMemory<char> authTypeValue = authType.Slice(typeKeyValueSepartorPosition + 1);

if (MemoryExtensions.Equals(authTypeValue.Span, Constants.Properties.AadToken.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
if (authorizationTokenLength > AuthorizationHelper.MaxAadAuthorizationHeaderSize)
{
DefaultTrace.TraceError($"Token of type [{authTypeValue.Span.ToString()}] was of size [{authorizationTokenLength}] while the max allowed size is [{AuthorizationHelper.MaxAadAuthorizationHeaderSize}].");
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat, SubStatusCodes.InvalidAuthHeaderFormat);
}
}
else if (MemoryExtensions.Equals(authTypeValue.Span, Constants.Properties.ResourceToken.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
if (authorizationTokenLength > AuthorizationHelper.MaxResourceTokenAuthorizationHeaderSize)
{
DefaultTrace.TraceError($"Token of type [{authTypeValue.Span.ToString()}] was of size [{authorizationTokenLength}] while the max allowed size is [{AuthorizationHelper.MaxResourceTokenAuthorizationHeaderSize}].");
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat, SubStatusCodes.InvalidAuthHeaderFormat);
}
}
else if (authorizationTokenLength > AuthorizationHelper.MaxAuthorizationHeaderSize)
{
DefaultTrace.TraceError($"Token of type [{authTypeValue.Span.ToString()}] was of size [{authorizationTokenLength}] while the max allowed size is [{AuthorizationHelper.MaxAuthorizationHeaderSize}].");
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat, SubStatusCodes.InvalidAuthHeaderFormat);
ReadOnlyMemory<char> authTypeValue = authType.Slice(typeKeyValueSepartorPosition + 1);

if (MemoryExtensions.Equals(authTypeValue.Span, Constants.Properties.AadToken.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
if (authorizationTokenLength > AuthorizationHelper.MaxAadAuthorizationHeaderSize)
{
DefaultTrace.TraceError($"Token of type [{authTypeValue.Span.ToString()}] was of size [{authorizationTokenLength}] while the max allowed size is [{AuthorizationHelper.MaxAadAuthorizationHeaderSize}].");
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat, SubStatusCodes.InvalidAuthHeaderFormat);
}
}
else if (MemoryExtensions.Equals(authTypeValue.Span, Constants.Properties.ResourceToken.AsSpan(), StringComparison.OrdinalIgnoreCase))
{
if (authorizationTokenLength > AuthorizationHelper.MaxResourceTokenAuthorizationHeaderSize)
{
DefaultTrace.TraceError($"Token of type [{authTypeValue.Span.ToString()}] was of size [{authorizationTokenLength}] while the max allowed size is [{AuthorizationHelper.MaxResourceTokenAuthorizationHeaderSize}].");
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat, SubStatusCodes.InvalidAuthHeaderFormat);
}
}
else if (authorizationTokenLength > AuthorizationHelper.MaxAuthorizationHeaderSize)
{
DefaultTrace.TraceError($"Token of type [{authTypeValue.Span.ToString()}] was of size [{authorizationTokenLength}] while the max allowed size is [{AuthorizationHelper.MaxAuthorizationHeaderSize}].");
throw new UnauthorizedException(RMResources.InvalidAuthHeaderFormat, SubStatusCodes.InvalidAuthHeaderFormat);
}

int versionKeyValueSeparatorPosition = version.Span.IndexOf('=');
Expand Down
Loading

0 comments on commit af9b009

Please sign in to comment.