Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: remove explicit org check in instancesController #564

Merged
merged 10 commits into from
Nov 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Storage/Altinn.Platform.Storage.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<PackageReference Include="Azure.Identity" Version="1.13.1" />
<PackageReference Include="Azure.Security.KeyVault.Secrets" Version="4.7.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.23.0" />
<PackageReference Include="Altinn.Common.PEP" Version="4.1.1" />
<PackageReference Include="Altinn.Common.PEP" Version="4.1.2" />
<PackageReference Include="Azure.Storage.Queues" Version="12.21.0" />

<PackageReference Include="JWTCookieAuthentication" Version="3.0.1" />
Expand Down
21 changes: 17 additions & 4 deletions src/Storage/Controllers/InstancesController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,25 @@ public async Task<ActionResult<QueryResponse<Instance>>> GetInstances(InstanceQu
{
queryParameters.Org = queryParameters.AppId.Split('/')[0];
}

if (!orgClaim.Equals(queryParameters.Org, StringComparison.InvariantCultureIgnoreCase))
{
return Forbid();
}

if (string.IsNullOrEmpty(queryParameters.AppId))
{
return BadRequest("AppId must be defined.");
}

var appId = ValidateAppId(queryParameters.AppId).Split("/")[1];

XacmlJsonRequestRoot request = DecisionHelper.CreateDecisionRequest(queryParameters.Org, appId, HttpContext.User, "read");
XacmlJsonResponse response = await _authorizationService.GetDecisionForRequest(request);

if (!DecisionHelper.ValidatePdpDecision(response?.Response, HttpContext.User))
{
return Forbid();
}
}

appOwnerRequestingInstances = true;
}
else if (userId != null)
Expand Down
Loading
Loading