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:
You can see all sorts of strange things in this code:
LightControllerdefines both this GetContext method (which is private) and a protected field _context, so there are two ways of accessing a LightContextfrom the controller. However, upon further inspection, one can see that the field isn't ever written to.
The method passes a IHttpContextAccessorto the LightContextconstructor. 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.
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.
As attested during the discussion on #198, the class
LightContext
has little semantic value for Liquid. It's a holder for aClaimsPrincipal
, just that.Now that #204 removed the authorization code from
LightWorker
,LightContext
is just used byLightController
, 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:
LightController
defines both thisGetContext
method (which is private) and a protected field_context
, so there are two ways of accessing aLightContext
from the controller. However, upon further inspection, one can see that the field isn't ever written to.The method passes a
IHttpContextAccessor
to theLightContext
constructor. This is stored in a public field of theLightContext
. Also, the User property is manually assigned to by the method with the User obtained from theHttpContext
. The same user that is available through _httpContextAccessor, so we are effectively transmitting the same data twice.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.