Skip to content

Commit 40b7642

Browse files
committed
feat: create scope package
BREAKING-CHANGE: This removes `IScopeAccessRequirement`, `ScopeAccessRequirement`, and `ScopeAccessHandler` from the `Altinn.Common.PEP` package. They have been moved to the new `Altinn.Authorization.Scopes` package and renamed to `IAnyOfScopeAuthorizationRequirement`. The implementation types have been made internal, and the handler is added using the extension method `AddAltinnScopesAuthorizationHandlers`.
1 parent a5ada47 commit 40b7642

19 files changed

+559
-299
lines changed

Altinn.Authorization.sln

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/apps/Altinn.AccessManagement/Altinn.AccessManagement.sln

Lines changed: 18 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/apps/Altinn.Authorization/Altinn.Authorization.sln

Lines changed: 15 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pkgs/Altinn.Authorization.PEP/Altinn.Authorization.PEP.sln

Lines changed: 20 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/pkgs/Altinn.Authorization.PEP/src/Altinn.Authorization.PEP/Authorization/IScopeAccessRequirement.cs

Lines changed: 0 additions & 16 deletions
This file was deleted.

src/pkgs/Altinn.Authorization.PEP/src/Altinn.Authorization.PEP/Authorization/ScopeAccessHandler.cs

Lines changed: 0 additions & 56 deletions
This file was deleted.

src/pkgs/Altinn.Authorization.PEP/src/Altinn.Authorization.PEP/Authorization/ScopeAccessRequirement.cs

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/pkgs/Altinn.Authorization.PEP/src/Altinn.Authorization.PEP/Extensions/AuthorizationBuilderExtensions.cs

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Altinn.Common.PEP.Authorization;
1+
using Altinn.Common.PEP.Authorization;
22
using Microsoft.AspNetCore.Authorization;
33

44
namespace Altinn.Authorization.PEP.Extensions;
@@ -41,20 +41,4 @@ public static AuthorizationBuilder AddAltinnPEPResourceAccessPolicy(this Authori
4141
ArgumentException.ThrowIfNullOrEmpty(actionType, nameof(actionType));
4242
return builder.AddPolicy(name, policy => policy.Requirements.Add(new ResourceAccessRequirement(resourceId, actionType)));
4343
}
44-
45-
/// <summary>
46-
/// Adds a scope-based access policy to the authorization builder.
47-
/// </summary>
48-
/// <param name="builder">The <see cref="AuthorizationBuilder"/> to which the policy will be added.</param>
49-
/// <param name="name">The name of the policy.</param>
50-
/// <param name="scopes">An array of scopes required by the policy.</param>
51-
/// <exception cref="ArgumentException">Thrown if <paramref name="name"/> is null or empty or if <paramref name="scopes"/> contains null or empty values.</exception>
52-
/// <exception cref="ArgumentNullException">Thrown if <paramref name="scopes"/> is null.</exception>
53-
/// <returns>The updated <see cref="AuthorizationBuilder"/>.</returns>
54-
public static AuthorizationBuilder AddAltinnPEPScopePolicy(this AuthorizationBuilder builder, string name, params string[] scopes)
55-
{
56-
ArgumentException.ThrowIfNullOrEmpty(name, nameof(name));
57-
ArgumentNullException.ThrowIfNull(scopes, nameof(scopes));
58-
return builder.AddPolicy(name, policy => policy.Requirements.Add(new ScopeAccessRequirement(scopes)));
59-
}
6044
}

src/pkgs/Altinn.Authorization.PEP/src/Altinn.Authorization.PEP/Extensions/ServiceCollectionExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Altinn.Common.PEP.Authorization;
1+
using Altinn.Common.PEP.Authorization;
22
using Microsoft.AspNetCore.Authorization;
33
using Microsoft.Extensions.DependencyInjection;
44
using Microsoft.Extensions.DependencyInjection.Extensions;
@@ -20,7 +20,6 @@ public static IServiceCollection AddAltinnPEP(this IServiceCollection services)
2020
{
2121
services.TryAddScoped<IAuthorizationHandler, ClaimAccessHandler>();
2222
services.TryAddScoped<IAuthorizationHandler, ResourceAccessHandler>();
23-
services.TryAddScoped<IAuthorizationHandler, ScopeAccessHandler>();
2423
return services;
2524
}
2625
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<Nullable>enable</Nullable>
5+
<LangVersion>13.0</LangVersion>
6+
</PropertyGroup>
7+
8+
<ItemGroup>
9+
<FrameworkReference Include="Microsoft.AspNetCore.App" />
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<InternalsVisibleTo Include="Altinn.Authorization.PEP.Tests" />
14+
</ItemGroup>
15+
16+
</Project>

0 commit comments

Comments
 (0)