Skip to content
This repository was archived by the owner on Aug 18, 2021. It is now read-only.
This repository was archived by the owner on Aug 18, 2021. It is now read-only.

Remove LightContext #205

Open
Open
@bruno-brant

Description

@bruno-brant

As attested during the discussion on #198, the class LightContext has little semantic value for Liquid. It's a holder for a ClaimsPrincipal, just that.

Now that #204 removed the authorization code from LightWorker, LightContext is just used by LightController, and in the most weird manner:

https://github.com/Avanade/Liquid-Application-Framework/blob/2ebc7fa6608f943434837948558b7939f2864fb9/src/Liquid.Activation/Controller/LightController.cs#L31-L37

You can see all sorts of strange things in this code:

  1. LightController defines both this GetContext method (which is private) and a protected field _context, so there are two ways of accessing a LightContext from the controller. However, upon further inspection, one can see that the field isn't ever written to.

  2. The method passes a IHttpContextAccessor to the LightContext constructor. This is stored in a public field of the LightContext. Also, the User property is manually assigned to by the method with the User obtained from the HttpContext. The same user that is available through _httpContextAccessor, so we are effectively transmitting the same data twice.

  3. The domain shouldn't access HTTP context data. This is a violation of the responsibility of the domain.

For all those reasons, I suggest we obsolete and remove LightContext, replacing it with more semantic types when necessary.

Metadata

Metadata

Assignees

No one assigned

    Labels

    complexity:highThe complexity of the issue is highenhancementNew feature or requestsize:smallThe size of the issue is small

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions