Skip to content

Commit f47112e

Browse files
authored
fix(app): Sub-parties sometimes missing from authorized parties (#1534)
<!--- Provide a general summary of your changes in the Title above --> ## Description <!--- Describe your changes in detail --> ## Related Issue(s) - #1226 ## Verification - [ ] **Your** code builds clean without any errors or warnings - [ ] Manual testing done (required) - [ ] Relevant automated test added (if you find this hard, leave it and we'll help out) ## Documentation - [ ] Documentation is updated (either in `docs`-directory, Altinnpedia or a separate linked PR in [altinn-studio-docs.](https://github.com/Altinn/altinn-studio-docs), if applicable) <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit - **Bug Fixes** - Removed unnecessary logging and reflection in cache handling, simplifying error management. - Temporarily disabled setting of sub-parties in the party flattening logic for ongoing development. - **Chores** - Removed the "Serilog" logging configuration from the app settings, streamlining the configuration file. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 3275d0d commit f47112e

File tree

2 files changed

+6
-35
lines changed

2 files changed

+6
-35
lines changed

src/Digdir.Domain.Dialogporten.GraphQL/appsettings.test.json

+1-9
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,5 @@
5959
}
6060
]
6161
}
62-
},
63-
"Serilog": {
64-
"MinimumLevel": {
65-
"Override": {
66-
"Digdir.Domain.Dialogporten.Infrastructure.Altinn.Authorization.AltinnAuthorizationClient": "Information",
67-
"Digdir.Domain.Dialogporten.GraphQL.EndUser.Queries": "Information"
68-
}
69-
}
70-
},
62+
}
7163
}

src/Digdir.Domain.Dialogporten.Infrastructure/Altinn/Authorization/AltinnAuthorizationClient.cs

+5-26
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System.Diagnostics;
2-
using System.Reflection;
32
using System.Text.Json;
43
using System.Text.Json.Serialization;
54
using Altinn.Authorization.ABAC.Xacml.JsonProfile;
@@ -9,7 +8,6 @@
98
using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
109
using Digdir.Domain.Dialogporten.Domain.Parties.Abstractions;
1110
using Digdir.Domain.Dialogporten.Infrastructure.Common.Exceptions;
12-
using Microsoft.Extensions.Caching.Memory;
1311
using Microsoft.Extensions.Logging;
1412
using ZiggyCreatures.Caching.Fusion;
1513

@@ -84,31 +82,9 @@ public async Task<AuthorizedPartiesResult> GetAuthorizedParties(IPartyIdentifier
8482
{
8583
var authorizedPartiesRequest = new AuthorizedPartiesRequest(authenticatedParty);
8684

87-
var cacheKey = authorizedPartiesRequest.GenerateCacheKey();
88-
var authorizedParties = await _partiesCache.GetOrSetAsync(cacheKey, async token
85+
var authorizedParties = await _partiesCache.GetOrSetAsync(authorizedPartiesRequest.GenerateCacheKey(), async token
8986
=> await PerformAuthorizedPartiesRequest(authorizedPartiesRequest, token), token: cancellationToken);
9087

91-
// Testing https://github.com/digdir/dialogporten/issues/1226
92-
try
93-
{
94-
var mcaField = typeof(FusionCache).GetField("_mca", BindingFlags.NonPublic | BindingFlags.Instance);
95-
var mcaValue = mcaField?.GetValue(_partiesCache);
96-
var mcField = mcaValue!.GetType().GetField("_cache", BindingFlags.NonPublic | BindingFlags.Instance);
97-
var mcValue = mcField?.GetValue(mcaValue) as IMemoryCache;
98-
99-
var inMemoryCacheValue = mcValue!.TryGetValue(cacheKey, out var inMemoryCacheEntry);
100-
var inMemoryCacheEntryValue = inMemoryCacheEntry?.GetType().GetProperty("Value")?.GetValue(inMemoryCacheEntry);
101-
102-
_logger.LogInformation("In memory cache value for {CacheKey}, success: {InMemoryCacheValue} value: {@inMemoryCacheEntryValue}",
103-
cacheKey, inMemoryCacheValue, inMemoryCacheEntryValue);
104-
}
105-
catch (Exception e)
106-
{
107-
_logger.LogError(e, "Failed to reflect on FusionCache MemoryCache");
108-
}
109-
110-
_logger.LogInformation("Authorized parties for {Party}: {@AuthorizedParties}", authenticatedParty, authorizedParties);
111-
11288
return flatten ? GetFlattenedAuthorizedParties(authorizedParties) : authorizedParties;
11389
}
11490

@@ -144,7 +120,10 @@ void Flatten(AuthorizedParty party, AuthorizedParty? parent = null)
144120
}
145121

146122
if (parent != null) party.ParentParty = parent.Party;
147-
party.SubParties = [];
123+
124+
// TODO: https://github.com/digdir/dialogporten/issues/1533
125+
// Disabling this for now, fixes https://github.com/digdir/dialogporten/issues/1226
126+
// party.SubParties = [];
148127

149128
flattenedAuthorizedParties.AuthorizedParties.Add(party);
150129
}

0 commit comments

Comments
 (0)