Skip to content

Commit

Permalink
cleanup references and test code, and FxCop Analyzers
Browse files Browse the repository at this point in the history
  • Loading branch information
msmolka committed Oct 11, 2019
1 parent 83f9feb commit 80e290c
Show file tree
Hide file tree
Showing 10 changed files with 280 additions and 224 deletions.
3 changes: 3 additions & 0 deletions CommonRuleSet.ruleset
Original file line number Diff line number Diff line change
Expand Up @@ -84,4 +84,7 @@
<Rule Id="SA1649" Action="None" />
<Rule Id="SA1652" Action="None" />
</Rules>
<Rules AnalyzerId="Microsoft.NetCore.Analyzers" RuleNamespace="Microsoft.NetCore.Analyzers">
<Rule Id="CA1303" Action="None" />
</Rules>
</RuleSet>
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ When you install the package, it should be added to your `.csproj`. Alternativel

```xml
<ItemGroup>
<PackageReference Include="ZNetCS.AspNetCore.Authentication.Basic" Version="3.0.1" />
<PackageReference Include="ZNetCS.AspNetCore.Authentication.Basic" Version="3.0.2" />
</ItemGroup>
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,14 @@ public static AuthenticationBuilder AddBasicAuthentication(
this AuthenticationBuilder builder,
string authenticationScheme,
Action<BasicAuthenticationOptions> configureOptions)
=> builder.AddScheme<BasicAuthenticationOptions, BasicAuthenticationHandler>(authenticationScheme, configureOptions);
{
if (builder == null)
{
throw new ArgumentNullException(nameof(builder));
}

return builder.AddScheme<BasicAuthenticationOptions, BasicAuthenticationHandler>(authenticationScheme, configureOptions);
}

#endregion
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ public BasicAuthenticationHandler(IOptionsMonitor<BasicAuthenticationOptions> op
protected override Task<object> CreateEventsAsync() => Task.FromResult<object>(new BasicAuthenticationEvents());

/// <inheritdoc/>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Design", "CA1031:Do not catch general exception types", Justification = "Just for validation, the quickest")]
[System.Diagnostics.CodeAnalysis.SuppressMessage("Globalization", "CA1307:Specify StringComparison", Justification = "Invalid overload; known bug in code analysis")]
protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
{
// RFC 7230 section 3.2.2
Expand All @@ -112,7 +114,7 @@ protected override async Task<AuthenticateResult> HandleAuthenticateAsync()
return AuthenticateResult.NoResult();
}

string basicAuthorizationHeader = authorizationHeaderValues.FirstOrDefault(s => s.StartsWith(Basic + ' ', StringComparison.OrdinalIgnoreCase));
string basicAuthorizationHeader = authorizationHeaderValues.FirstOrDefault(s => s.StartsWith(Basic + ' ', StringComparison.InvariantCultureIgnoreCase));

// Authorization header is not 'Basic' so there is nothing to do by this middleware
if (string.IsNullOrEmpty(basicAuthorizationHeader))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,54 +4,54 @@
<Description>A simple basic authentication middleware.</Description>
<Copyright>Marcin Smółka zNET Computer Solutions</Copyright>
<Authors>Marcin Smółka</Authors>
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<TargetFrameworks>net461;netstandard2.0;netcoreapp3.0</TargetFrameworks>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<AssemblyName>ZNetCS.AspNetCore.Authentication.Basic</AssemblyName>
<PackageId>ZNetCS.AspNetCore.Authentication.Basic</PackageId>
<PackageTags>aspnetcore;aspnetcoremvc;middleware;authentication;basic;ASP.NET;MVC</PackageTags>
<PackageProjectUrl>https://github.com/msmolka/ZNetCS.AspNetCore.Authentication.Basic</PackageProjectUrl>
<PackageLicenseUrl>https://raw.githubusercontent.com/msmolka/ZNetCS.AspNetCore.Authentication.Basic/master/LICENSE</PackageLicenseUrl>
<PackageReleaseNotes>Cleanup dependencies.</PackageReleaseNotes>
<RepositoryType>git</RepositoryType>
<RepositoryUrl>https://github.com/msmolka/ZNetCS.AspNetCore.Authentication.Basic</RepositoryUrl>
<VersionPrefix>3.0.1</VersionPrefix>
<NoWarn>$(NoWarn);NU5125</NoWarn> <!-- remove once tools are truly ready for NuGet's new 'license' element -->
<VersionPrefix>3.0.2</VersionPrefix>
<NoWarn>$(NoWarn);NU5125</NoWarn>
<!-- remove once tools are truly ready for NuGet's new 'license' element -->
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute>
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute>
<GenerateAssemblyTitleAttribute>false</GenerateAssemblyTitleAttribute>
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute>
<GenerateAssemblyCopyrightAttribute>false</GenerateAssemblyCopyrightAttribute>
<CodeAnalysisRuleSet>..\..\CommonRuleSet.ruleset</CodeAnalysisRuleSet>
<LangVersion>8.0</LangVersion>
</PropertyGroup>

<ItemGroup>
<AdditionalFiles Include="..\..\stylecop.json" Link="stylecop.json" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>..\..\CommonRuleSet.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Debug|net461|AnyCPU'">
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(TargetFramework)|$(Platform)'=='Release|net461|AnyCPU'">
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
<TreatWarningsAsErrors />
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
<PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Options" Version="2.2.0" />
<PackageReference Include="Microsoft.Net.Http.Headers" Version="2.2.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.1-rc.114">
<PrivateAssets>All</PrivateAssets>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0-beta2-19367-01" PrivateAssets="all" />
<PackageReference Include="Microsoft.CodeAnalysis.FxCopAnalyzers" Version="2.9.6">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>

<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
<Reference Include="System" />
<Reference Include="Microsoft.CSharp" />
<ItemGroup Condition="'$(TargetFramework)' == 'netcoreapp3.0'">
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net461' OR '$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.AspNetCore.Authentication" Version="2.2.0" />
</ItemGroup>

</Project>
Loading

0 comments on commit 80e290c

Please sign in to comment.