< Summary - Heimdall API

Information
Class: ArturRios.Heimdall.WebApi.Security.ActorExtensions
Assembly: ArturRios.Heimdall.WebApi
File(s): /home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Security/ActorExtensions.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 25
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage
100%
Covered methods: 1
Fully covered methods: 1
Total methods: 1
Method coverage: 100%
Full method coverage: 100%

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ApplyActor(...)100%11100%

File(s)

/home/runner/work/heimdall-api/heimdall-api/src/Presentation/ArturRios.Heimdall.WebApi/Security/ActorExtensions.cs

#LineLine coverage
 1using ArturRios.Heimdall.Shared.Security;
 2using ArturRios.Util.WebApi.Security.Extensions;
 3
 4namespace ArturRios.Heimdall.WebApi.Security;
 5
 6/// <summary>
 7///     Bridges the authenticated caller on the request to the actor-scoped commands and queries whose
 8///     authorization depends on who is acting.
 9/// </summary>
 10public static class ActorExtensions
 11{
 12    /// <summary>
 13    ///     Copies the authenticated caller (attached to the request by the auth middleware) onto an
 14    ///     actor-scoped command or query, so the handler can enforce scope-scoped authorization
 15    ///     (UC-02 AF-02b, UC-06 AF-06e, UC-07 AF-07b). The acting fields are always taken from the
 16    ///     token, never from the request.
 17    /// </summary>
 18    public static void ApplyActor(this HttpContext httpContext, IActorScoped actorScoped)
 19    {
 61520        var actor = httpContext.GetUser<IdentityUser>()!;
 21
 61522        actorScoped.ActingPersonId = actor.Id;
 61523        actorScoped.ActingRole = actor.RoleId;
 61524    }
 25}