feat(#2114): expose viaRole on connection sub-connections - #3895
Conversation
When listing connections for a party, sub-connections show which parties inherit the parent's access, but not why. A person nested under an organisation gave the GUI no way to say that they are there because they hold a key role in it. The connection query already carries the via role on every record and the entity enricher already resolves it to a full Role, so this only adds the field to ConnectionDto and maps it in the two sub-connection mappers. It stays null on top-level connections and on relations that carry no role, such as a plain main-unit hierarchy. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
howieandersen
left a comment
There was a problem hiding this comment.
Liten og ryddig, og testene dekker maskeringstilfellet godt. En ting bør avklares før merge.
DtoMapperConnectionQuery.cs:150 og DtoMapperConnectionQuery.cs:200: c.FirstOrDefault(t => t.ViaRole is not null) er ikke deterministisk når samme part når forelderen gjennom flere records med ulik via-rolle, for eksempel en person som er både DAGL og LEDE i samme selskap. Da er det radrekkefølgen fra spørringen som avgjør hvilken rolle GUI-et viser, og den kan variere mellom kall siden enrich-spørringen ikke har noen ORDER BY. Forslag: velg deterministisk innenfor gruppen, for eksempel OrderBy på rollekode før FirstOrDefault, eller prioriter KeyRole-records foran klientdelegering om det er semantikken dere er ute etter. Si i så fall også i XML-doc-en hvilken rolle som vinner når det finnes flere.
Ellers ingenting. Kontraktendringen er additiv og følger samme mønster som PermissionDto.
Description
Adds a
viaRolefield toConnectionDto, populated on sub-connections so the GUI can show why a party appears nested under another one.In the issue's scenario the caller lists who has access to their own party.
Regnskapsheltenholds the access, andJanne Daglshows up beneath it because she is daglig leder there. Until now the response said Janne was a sub-connection but not what made her one.The plumbing already existed —
ConnectionBaseQueryBuildersetsViaRoleIdon every key-role and client-delegation record, andConnectionEntityEnricheralready resolves it to a fullRole. The value was simply dropped in the mapper. This change adds the field to the contract and maps it inConvertSubConnectionsToOthers/ConvertSubConnectionsFromOthers.Behaviour:
null, as the issue asks.nullwhen the relation carries no role, e.g. a plain main-unit hierarchy record.Purely additive, so no existing consumer breaks. The frontend has
viaRoleon permissions today but not on connections, so nothing needs to change there until the GUI starts rendering it.Note for review
A person can hold more than one key role in the same organisation (for example both dagl and styreleder). The issue asks for a single
viaRole, so that is what this implements, and the second role is not surfaced. If @allinox wants all of them shown, adding aviaRoleslist later is an additive follow-up.Related Issue(s)
Verification
5 unit tests added to
DtoMapperConnectionQueryTest, covering the issue's key-role scenario end to end throughConvertToOthers, both sub-connection mappers, the null cases, and the masking case. Verified they are not vacuous: reverting the mapper change makes exactly the 3 positive tests fail. FullAltinn.AccessMgmt.Core.Testsunit suite green (the only local failures are integration tests that need Docker, which is not running here).Documentation
🤖 Generated with Claude Code