Skip to content

Commit 3f56fcc

Browse files
author
Jakab László
committed
Fix PR comments
1 parent 2d4a3f2 commit 3f56fcc

11 files changed

+58
-20
lines changed

AutSoftCore.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tools", "Tools", "{4E394277
3232
README.md = README.md
3333
EndProjectSection
3434
EndProject
35+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AutSoft.AspNetCore.Auth", "src\AutSoft.AspNetCore.Auth\AutSoft.AspNetCore.Auth.csproj", "{6B158B44-E28E-4276-BB65-72CDA4163F39}"
36+
EndProject
3537
Global
3638
GlobalSection(SolutionConfigurationPlatforms) = preSolution
3739
Debug|Any CPU = Debug|Any CPU
@@ -62,6 +64,10 @@ Global
6264
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Debug|Any CPU.Build.0 = Debug|Any CPU
6365
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Release|Any CPU.ActiveCfg = Release|Any CPU
6466
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88}.Release|Any CPU.Build.0 = Release|Any CPU
67+
{6B158B44-E28E-4276-BB65-72CDA4163F39}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
68+
{6B158B44-E28E-4276-BB65-72CDA4163F39}.Debug|Any CPU.Build.0 = Debug|Any CPU
69+
{6B158B44-E28E-4276-BB65-72CDA4163F39}.Release|Any CPU.ActiveCfg = Release|Any CPU
70+
{6B158B44-E28E-4276-BB65-72CDA4163F39}.Release|Any CPU.Build.0 = Release|Any CPU
6571
EndGlobalSection
6672
GlobalSection(SolutionProperties) = preSolution
6773
HideSolutionNode = FALSE
@@ -73,6 +79,7 @@ Global
7379
{FF908529-9DDE-4DFB-ABA9-A2045E715B21} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
7480
{28371EF8-D3D3-40CA-AAE9-29D80AE0BF3F} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
7581
{D4D62897-E6D6-484E-AE4E-F3A0347ADD88} = {7029D162-AEB0-4B68-A21E-90ABCD21DAD3}
82+
{6B158B44-E28E-4276-BB65-72CDA4163F39} = {C46AA3F7-CBFE-428A-AA49-D1A1D40AB8A6}
7683
EndGlobalSection
7784
GlobalSection(ExtensibilityGlobals) = postSolution
7885
SolutionGuid = {E4767DF1-41A6-4BF0-A957-2718986D8BC7}

src/AutSoft.All/AutSoft.All.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10+
<ProjectReference Include="..\AutSoft.AspNetCore.Auth\AutSoft.AspNetCore.Auth.csproj" />
1011
<ProjectReference Include="..\AutSoft.DbScaffolding.Identity\AutSoft.DbScaffolding.Identity.csproj" />
1112
<ProjectReference Include="..\AutSoft.Linq\AutSoft.Linq.csproj" />
1213
</ItemGroup>

src/AutSoft.All/ServiceCollectionExtensions.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
using AutSoft.AspNetCore.Auth;
12
using AutSoft.Common;
23

34
using Microsoft.Extensions.DependencyInjection;
@@ -15,6 +16,9 @@ public static class ServiceCollectionExtensions
1516
/// <returns>Expanded service collection</returns>
1617
public static IServiceCollection AddAutSoftAll(this IServiceCollection services)
1718
{
18-
return services.AddAutSoftCommon();
19+
services.AddAutSoftAspNetCoreAuth();
20+
services.AddAutSoftCommon();
21+
22+
return services;
1923
}
2024
}

src/AutSoft.Core/AnyPolicies/AnyPoliciesAuthorizationHandler.cs renamed to src/AutSoft.AspNetCore.Auth/AnyPolicies/AnyPoliciesAuthorizationHandler.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
using Microsoft.AspNetCore.Authorization;
22
using Microsoft.Extensions.DependencyInjection;
33

4-
namespace AutSoft.Common.AnyPolicies;
4+
namespace AutSoft.AspNetCore.Auth.AnyPolicies;
55

66
/// <summary>
77
/// Evulate the policies in the <see cref="AnyPoliciesRequirement"/> with OR relationship,
8-
/// so it is enough for a policy to pass the test
8+
/// so it is enough for one policy to pass the authorization requirement
99
/// </summary>
1010
public class AnyPoliciesAuthorizationHandler : AuthorizationHandler<AnyPoliciesRequirement>
1111
{
@@ -15,11 +15,9 @@ public class AnyPoliciesAuthorizationHandler : AuthorizationHandler<AnyPoliciesR
1515
/// Initialize a new instance of the <see cref="AnyPoliciesAuthorizationHandler"/> class.
1616
/// </summary>
1717
/// <param name="serviceProvider">An instance of <see cref="IServiceProvider"/></param>
18-
/// <remarks>
19-
/// Not possible to inject <see cref="IAuthorizationService"/>, because it would be a circular reference
20-
/// </remarks>
2118
public AnyPoliciesAuthorizationHandler(IServiceProvider serviceProvider)
2219
{
20+
// Not possible to inject IAuthorizationService, because it would be a circular reference
2321
_serviceProvider = serviceProvider;
2422
}
2523

src/AutSoft.Core/AnyPolicies/AnyPoliciesAuthorizeAttribute.cs renamed to src/AutSoft.AspNetCore.Auth/AnyPolicies/AnyPoliciesAuthorizeAttribute.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.AspNetCore.Authorization;
22

3-
namespace AutSoft.Common.AnyPolicies;
3+
namespace AutSoft.AspNetCore.Auth.AnyPolicies;
44

55
/// <summary>
66
/// The policies, which are specified in the constructor or <see cref="Policies"/> property
@@ -20,7 +20,6 @@ public class AnyPoliciesAuthorizeAttribute : AuthorizeAttribute
2020
public string[] Policies
2121
{
2222
get => _policies;
23-
2423
set
2524
{
2625
_policies = value;

src/AutSoft.Core/AnyPolicies/AnyPoliciesPolicyProvider.cs renamed to src/AutSoft.AspNetCore.Auth/AnyPolicies/AnyPoliciesPolicyProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using Microsoft.AspNetCore.Authorization;
33
using Microsoft.Extensions.Options;
44

5-
namespace AutSoft.Common.AnyPolicies;
5+
namespace AutSoft.AspNetCore.Auth.AnyPolicies;
66

77
/// <summary>
88
/// Dynamically generate policies based on <see cref="AnyPoliciesAuthorizeAttribute"/>,

src/AutSoft.Core/AnyPolicies/AnyPoliciesRequirement.cs renamed to src/AutSoft.AspNetCore.Auth/AnyPolicies/AnyPoliciesRequirement.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Microsoft.AspNetCore.Authorization;
22

3-
namespace AutSoft.Common.AnyPolicies;
3+
namespace AutSoft.AspNetCore.Auth.AnyPolicies;
44

55
/// <summary>
66
/// Requirement of wanted to combine OR authorizations
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>net6.0</TargetFramework>
5+
<ImplicitUsings>enable</ImplicitUsings>
6+
<Nullable>enable</Nullable>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
11+
<PackageReference Include="Microsoft.AspNetCore.Authorization" />
12+
</ItemGroup>
13+
14+
</Project>
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using AutSoft.AspNetCore.Auth.AnyPolicies;
2+
3+
using Microsoft.AspNetCore.Authorization;
4+
using Microsoft.Extensions.DependencyInjection;
5+
6+
namespace AutSoft.AspNetCore.Auth;
7+
8+
/// <summary>
9+
/// Register all relevant services into dependency injection container
10+
/// </summary>
11+
public static class ServiceCollectionExtensions
12+
{
13+
/// <summary>
14+
/// Register all relevant services into dependency injection container
15+
/// </summary>
16+
/// <returns>Expanded service collection</returns>
17+
public static IServiceCollection AddAutSoftAspNetCoreAuth(this IServiceCollection services)
18+
{
19+
services.AddSingleton<IAuthorizationPolicyProvider, AnyPoliciesPolicyProvider>();
20+
services.AddSingleton<IAuthorizationHandler, AnyPoliciesAuthorizationHandler>();
21+
22+
return services;
23+
}
24+
}

src/AutSoft.Core/AutSoft.Common.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" />
11-
<PackageReference Include="Microsoft.AspNetCore.Authorization" />
1210
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
1311
<PackageReference Include="Microsoft.EntityFrameworkCore" />
1412
<PackageReference Include="Stateless" />

0 commit comments

Comments
 (0)