Ejemplo n.º 1
0
        static CabinizerPrincipal()
        {
            var identity = new ClaimsIdentity("System");

            identity.AddClaim(new Claim(GoogleClaimTypes.Sub, Constants.SystemUserId));

            var principal = new ClaimsPrincipal(identity);

            System = new CabinizerPrincipal(principal);
        }
            public async Task Invoke(HttpContext httpContext, CabinizerContext context)
            {
                if (httpContext.User.Identity.IsAuthenticated)
                {
                    var user = new CabinizerPrincipal(httpContext.User);

                    var orgUnitPath = await Cache.GetOrCreateAsync(user.Id, entry => GetOrgUnitPath(entry, context));

                    var identity = new ClaimsIdentity("Cabinizer");

                    identity.AddClaim(new Claim(CustomClaimTypes.OrgUnitPath, orgUnitPath));

                    httpContext.User.AddIdentity(identity);
                }

                await Next(httpContext);
            }