Skip to content

Commit

Permalink
Added auth config
Browse files Browse the repository at this point in the history
  • Loading branch information
Ceredron committed Jan 22, 2025
1 parent e3c1724 commit 7d17dbe
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Storage/Controllers/SblBridgeController.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
using System;
using System.Threading.Tasks;
using Altinn.Platform.Storage.Clients;
using Altinn.Platform.Storage.Helpers;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -10,6 +12,7 @@ namespace Altinn.Platform.Storage.Controllers
/// API for use by Correspondence to support legacy solution by routing request to SBL Bridge
/// </summary>
[Route("storage/api/v1/sblbridge")]
[ApiController]
public class SblBridgeController : ControllerBase
{
/// <summary>
Expand All @@ -27,6 +30,7 @@ public SblBridgeController(IPartiesWithInstancesClient partiesWithInstancesClien
/// </summary>
/// <param name="partyId">The party id that has become an Altinn 3 Correspondence recipient</param>
[HttpPost("correspondencerecipient")]
[Authorize(Policy = AuthzConstants.POLICY_CORRESPONDENCE_SBLBRIDGE)]
[ProducesResponseType(StatusCodes.Status200OK)]
[ProducesResponseType(StatusCodes.Status400BadRequest)]
[Produces("application/json")]
Expand Down
5 changes: 5 additions & 0 deletions src/Storage/Helpers/AuthzConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,10 @@ public static class AuthzConstants
/// Policy tag for authorizing designer access
/// </summary>
public const string POLICY_STUDIO_DESIGNER = "StudioDesignerAccess";

/// <summary>
/// Policy tag for authorizing correspondence calls to SBL bridge
/// </summary>
public const string POLICY_CORRESPONDENCE_SBLBRIDGE = "CorrespondenceSblBridge";
}
}
2 changes: 1 addition & 1 deletion src/Storage/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,6 @@ void ConfigureServices(IServiceCollection services, IConfiguration config)
services.AddSingleton<IPublicSigningKeyProvider, PublicSigningKeyProvider>();

GeneralSettings generalSettings = config.GetSection("GeneralSettings").Get<GeneralSettings>();

services.AddAuthentication(JwtCookieDefaults.AuthenticationScheme)
.AddJwtCookie(JwtCookieDefaults.AuthenticationScheme, options =>
{
Expand Down Expand Up @@ -231,6 +230,7 @@ void ConfigureServices(IServiceCollection services, IConfiguration config)
.AddPolicy(AuthzConstants.POLICY_INSTANCE_SIGN, policy => policy.Requirements.Add(new AppAccessRequirement("sign")))
.AddPolicy(AuthzConstants.POLICY_SCOPE_APPDEPLOY, policy => policy.Requirements.Add(new ScopeAccessRequirement("altinn:appdeploy")))
.AddPolicy(AuthzConstants.POLICY_STUDIO_DESIGNER, policy => policy.Requirements.Add(new ClaimAccessRequirement("urn:altinn:app", "studio.designer")))
.AddPolicy(AuthzConstants.POLICY_CORRESPONDENCE_SBLBRIDGE, policy => policy.Requirements.Add(new ScopeAccessRequirement("altinn:correspondence.sblbridge")))
.AddPolicy("PlatformAccess", policy => policy.Requirements.Add(new AccessTokenRequirement()));

services.AddSingleton<ClientIpCheckActionFilterAttribute>(container =>
Expand Down

0 comments on commit 7d17dbe

Please sign in to comment.