|
1 | 1 | using System.Diagnostics;
|
2 |
| -using System.Reflection; |
3 | 2 | using System.Text.Json;
|
4 | 3 | using System.Text.Json.Serialization;
|
5 | 4 | using Altinn.Authorization.ABAC.Xacml.JsonProfile;
|
|
9 | 8 | using Digdir.Domain.Dialogporten.Domain.Dialogs.Entities;
|
10 | 9 | using Digdir.Domain.Dialogporten.Domain.Parties.Abstractions;
|
11 | 10 | using Digdir.Domain.Dialogporten.Infrastructure.Common.Exceptions;
|
12 |
| -using Microsoft.Extensions.Caching.Memory; |
13 | 11 | using Microsoft.Extensions.Logging;
|
14 | 12 | using ZiggyCreatures.Caching.Fusion;
|
15 | 13 |
|
@@ -84,31 +82,9 @@ public async Task<AuthorizedPartiesResult> GetAuthorizedParties(IPartyIdentifier
|
84 | 82 | {
|
85 | 83 | var authorizedPartiesRequest = new AuthorizedPartiesRequest(authenticatedParty);
|
86 | 84 |
|
87 |
| - var cacheKey = authorizedPartiesRequest.GenerateCacheKey(); |
88 |
| - var authorizedParties = await _partiesCache.GetOrSetAsync(cacheKey, async token |
| 85 | + var authorizedParties = await _partiesCache.GetOrSetAsync(authorizedPartiesRequest.GenerateCacheKey(), async token |
89 | 86 | => await PerformAuthorizedPartiesRequest(authorizedPartiesRequest, token), token: cancellationToken);
|
90 | 87 |
|
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 |
| - |
112 | 88 | return flatten ? GetFlattenedAuthorizedParties(authorizedParties) : authorizedParties;
|
113 | 89 | }
|
114 | 90 |
|
@@ -144,7 +120,10 @@ void Flatten(AuthorizedParty party, AuthorizedParty? parent = null)
|
144 | 120 | }
|
145 | 121 |
|
146 | 122 | 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 = []; |
148 | 127 |
|
149 | 128 | flattenedAuthorizedParties.AuthorizedParties.Add(party);
|
150 | 129 | }
|
|
0 commit comments