public UserPermissionAuthorizer(IUserContext userContext, IPermissionAuthorizationMatcher permissionAuthorizationMatcher, IUserPermissionResolver userPermissionResolver) { this.userContext = userContext; this.permissionAuthorizationMatcher = permissionAuthorizationMatcher; this.userPermissionResolver = userPermissionResolver; }
public UserPermissionAuthorizerTests() { userContext = new FakeUserContext(); permissionAuthorizationMatcher = Substitute.For <IPermissionAuthorizationMatcher>(); userPermissionResolver = Substitute.For <IUserPermissionResolver>(); permissionType1Id = Guid.Parse("0F292EFD-792E-48EC-93DF-CD99EEDB5885"); sut = new UserPermissionAuthorizer(userContext, permissionAuthorizationMatcher, userPermissionResolver); }
public UserPermissionAuthorizerTests() { userContext = new FakeUserContext(); permissionAuthorizationMatcher = Substitute.For <IPermissionAuthorizationMatcher>(); userPermissionResolver = Substitute.For <IUserPermissionResolver>(); permissionTypeRegistry = Substitute.For <IPermissionTypeRegistry>(); permissionTypeRegistry.GetPermissionTypeById(Guid.Parse("0F292EFD-792E-48EC-93DF-CD99EEDB5885")) .Returns(new PermissionType(Guid.Parse("0F292EFD-792E-48EC-93DF-CD99EEDB5885"), "permission")); sut = new UserPermissionAuthorizer(userContext, permissionAuthorizationMatcher, userPermissionResolver, permissionTypeRegistry); }
public AspNetUserContext( [Optional] IAuthenticationManager authenticationManager, IUserPermissionResolver userPermissionResolver, IUserStore <IIdentityUser, Guid> userStore) { this.authenticationManager = authenticationManager; this.userPermissionResolver = userPermissionResolver; this.userStore = userStore; userIdLazy = new Lazy <Guid?>(() => { string userIdString = authenticationManager?.User?.Identity?.GetUserId <string>(); return(userIdString != null ? ((Guid?)Guid.Parse(userIdString)) : null); }); }
public AspNetCoreUserContext(IUserPermissionResolver userPermissionResolver, IClaimsPrincipalUserResolver claimsPrincipalUserResolver, IHttpContextAccessor httpContextAccessor) { this.userPermissionResolver = userPermissionResolver; this.claimsPrincipalUserResolver = claimsPrincipalUserResolver; this.httpContextAccessor = httpContextAccessor; userIdLazy = new Lazy <Guid?>(() => { var httpContext = httpContextAccessor.HttpContext; if (httpContext?.User?.Identity?.IsAuthenticated ?? false) { var claimsPrincipal = httpContext.User; return(claimsPrincipalUserResolver.TryGetUserId(claimsPrincipal)); } return(null); }); }
public AspNetCoreUserContext(IUserPermissionResolver userPermissionResolver, IUserManager userManager, IHttpContextAccessor httpContextAccessor) { this.userPermissionResolver = userPermissionResolver; this.userManager = userManager; this.httpContextAccessor = httpContextAccessor; userIdLazy = new Lazy <Guid?>(() => { var httpContext = httpContextAccessor.HttpContext; if (httpContext?.User?.Identity?.IsAuthenticated ?? false) { var claimsPrincipal = httpContext.User; string userIdString = userManager.GetUserId(claimsPrincipal); return(userIdString != null ? (Guid?)Guid.Parse(userIdString) : null); } return(null); }); }