public CredentialsService( UserManager <AppUserEntity> userManager, IEmailService emailService, ILoginService loginService, IIdentityUIUserInfoService identityUIUserInfoService, IValidator <RecoverPasswordRequest> forgotPasswordValidator, IValidator <ResetPasswordRequest> recoverPasswordValidator, IValidator <ChangePasswordRequest> changePasswordValidator, IValidator <CreatePasswordRequest> createPasswordValidator, ILogger <CredentialsService> logger, IOptionsSnapshot <IdentityUIOptions> identityManagementOptions, IOptionsSnapshot <IdentityUIEndpoints> identityManagementEndpoints) { _userManager = userManager; _emailService = emailService; _loginService = loginService; _identityUIUserInfoService = identityUIUserInfoService; _forgotPasswordValidator = forgotPasswordValidator; _recoverPasswordValidator = recoverPasswordValidator; _changePasswordValidator = changePasswordValidator; _createPasswordValidator = createPasswordValidator; _logger = logger; _identityManagementOptions = identityManagementOptions.Value; _identityManagementEndpoints = identityManagementEndpoints.Value; }
public GroupUserStore( IBaseRepository <GroupUserEntity> groupUserRepository, IBaseRepository <RoleEntity> roleRepository, IBaseRepository <RoleAssignmentEntity> roleAssignmentRepository, IBaseDAO <GroupUserEntity> groupUserDAO, IBaseDAO <RoleAssignmentEntity> roleAssignmentDAO, IBaseDAO <RoleEntity> roleDAO, IOptions <IdentityUIClaimOptions> identityUIClaimOptions, IIdentityUIUserInfoService identityUIUserInfoService, ILogger <GroupUserStore> logger) { _groupUserRepository = groupUserRepository; _roleRepository = roleRepository; _roleAssignmentRepository = roleAssignmentRepository; _groupUserDAO = groupUserDAO; _roleAssignmentDAO = roleAssignmentDAO; _roleDAO = roleDAO; _identityUIClaimOptions = identityUIClaimOptions.Value; _identityUIUserInfoService = identityUIUserInfoService; _logger = logger; }
public ExternalLoginService( SignInManager <AppUserEntity> signInManager, UserManager <AppUserEntity> userManager, IIdentityUIUserInfoService identityUIUserInfoService, ISessionService sessionService, ILoginFilter canLoginService, IOptions <IdentityUIOptions> identityUIOptions, IOptions <IdentityUIEndpoints> identityUIEndpoints, IValidator <ExternalLoginRequest> externalLoginRequestValidator, ILogger <ExternalLoginService> logger) { _signInManager = signInManager; _userManager = userManager; _identityUIUserInfoService = identityUIUserInfoService; _sessionService = sessionService; _canLoginService = canLoginService; _identityUIOptions = identityUIOptions.Value; _identityUIEndpoints = identityUIEndpoints.Value; _externalLoginRequestValidator = externalLoginRequestValidator; _logger = logger; }
public DashboardController( IGroupAdminDashboardService groupAdminDashboardService, IIdentityUIUserInfoService identityUIUserInfoService) { _groupAdminDashboardService = groupAdminDashboardService; _identityUIUserInfoService = identityUIUserInfoService; }
public GroupStore(IBaseRepository <GroupEntity> groupRepository, IBaseDAO <GroupEntity> groupDAO, IIdentityUIUserInfoService identityUIUserInfoService, ILogger <GroupStore> logger) { _groupRepository = groupRepository; _groupDAO = groupDAO; _identityUIUserInfoService = identityUIUserInfoService; _logger = logger; }
public IdentityUIAuditSubjectService( IHttpContextAccessor httpContextAccessor, IIdentityUIUserInfoService identityUIUserInfoService, IOptions <AuditOptions> auditOptions, IOptions <IdentityUIClaimOptions> identityUIClaimOptions) : base(httpContextAccessor, auditOptions) { _identityUIUserInfoService = identityUIUserInfoService; _identityUIClaimOptions = identityUIClaimOptions.Value; }
public void OnAuthorization(AuthorizationFilterContext context) { IIdentityUIUserInfoService identityUIUserInfoService = context.HttpContext.RequestServices.GetRequiredService <IIdentityUIUserInfoService>(); bool hasPermission = identityUIUserInfoService.HasPermission(_permission); if (!hasPermission) { context.Result = new ForbidResult(); return; } }
public void OnAuthorization(AuthorizationFilterContext context) { IIdentityUIUserInfoService identityUIUserInfoService = context.HttpContext.RequestServices.GetRequiredService <IIdentityUIUserInfoService>(); bool hasRole = identityUIUserInfoService.HasRole(IdentityUIRoles.IDENTITY_MANAGMENT_ROLE); if (hasRole) { return; } context.Result = new ForbidResult(); }
public AuditDataService( IBaseDAO <AuditEntity> auditDAO, IIdentityUIUserInfoService identityUIUserInfoService, IValidator <DataTableRequest> dataTableRequestValidator, IValidator <AuditTableRequest> auditTableRequestValidator, ILogger <AuditDataService> logger) { _auditDAO = auditDAO; _identityUIUserInfoService = identityUIUserInfoService; _dataTableRequestValidator = dataTableRequestValidator; _auditTableRequestValidator = auditTableRequestValidator; _logger = logger; }
public void OnAuthorization(AuthorizationFilterContext context) { IIdentityUIUserInfoService identityUIUserInfoService = context.HttpContext.RequestServices.GetRequiredService <IIdentityUIUserInfoService>(); bool isIdentityAdmin = identityUIUserInfoService.HasPermission(_requirePermission); if (isIdentityAdmin) { return; } bool isInRequiredRole = identityUIUserInfoService.HasGroupPermission(_requirePermission); if (!isInRequiredRole) { context.Result = new ForbidResult(); return; } bool groupIdExist = context.RouteData.Values.TryGetValue(GROUP_ROUTE_KEY, out object groupIdObj); if (!groupIdExist) { context.Result = new NotFoundResult(); } string groupId = (string)groupIdObj; string logedInUserId = context.HttpContext.User.GetUserId(); BaseSpecification <GroupUserEntity> baseSpecification = new BaseSpecification <GroupUserEntity>(); baseSpecification.AddFilter(x => x.UserId == logedInUserId); baseSpecification.AddFilter(x => x.GroupId == groupId); baseSpecification.AddFilter(x => x.Role.Permissions.Any(c => c.Permission.Name.ToUpper() == _requirePermission.ToUpper())); IBaseRepository <GroupUserEntity> groupUserRepository = context.HttpContext.RequestServices.GetService <IBaseRepository <GroupUserEntity> >(); bool groupUserExist = groupUserRepository.Exist(baseSpecification); if (!groupUserExist) { //_logger.LogError($"User does not have permission for group. UserId {logedInUserId}, {groupId}"); context.Result = new ForbidResult(); return; } }
public TwoFactorAuthenticationDataService( UserManager <AppUserEntity> userManager, IBaseRepository <AppUserEntity> userRepository, ITwoFactorAuthService twoFactorAuthService, IIdentityUIUserInfoService identityUIUserInfoService, IOptions <IdentityUIEndpoints> options, ILogger <TwoFactorAuthenticationDataService> logger) { _userManager = userManager; _userRepository = userRepository; _twoFactorAuthService = twoFactorAuthService; _identityUIUserInfoService = identityUIUserInfoService; _options = options.Value; _logger = logger; }
public ImpersonateService( SignInManager <AppUserEntity> signInManager, UserManager <AppUserEntity> userManager, IGroupUserStore groupUserStore, ISessionService sessionService, IIdentityUIUserInfoService identityUIUserInfoService, ILogger <ImpersonateService> logger) { _signInManager = signInManager; _userManager = userManager; _groupUserStore = groupUserStore; _sessionService = sessionService; _identityUIUserInfoService = identityUIUserInfoService; _logger = logger; }
/// <summary> /// Configures IdentityUI /// </summary> /// <param name="services"></param> /// <param name="configuration"></param> /// <param name="endpointAction"></param> /// <returns></returns> public static IdentityUIServicesBuilder ConfigureIdentityUI(this IServiceCollection services, IConfiguration configuration, Action <IdentityUIEndpoints> endpointAction) { IdentityUIOptions identityUIOptions = configuration.GetSection("IdentityUI").Get <IdentityUIOptions>(); if (identityUIOptions == null) { identityUIOptions = new IdentityUIOptions(); } services.Configure <IdentityUIOptions>(options => { options.BasePath = identityUIOptions.BasePath; options.Database = identityUIOptions.Database; options.EmailSender = identityUIOptions.EmailSender; }); services.Configure <ReCaptchaOptions>(options => { options.SiteKey = identityUIOptions.ReCaptcha?.SiteKey; options.SiteSecret = identityUIOptions.ReCaptcha?.SiteSecret; }); DatabaseOptions databaseOptions = new DatabaseOptions { Type = identityUIOptions.Database?.Type ?? DatabaseTypes.InMemory, ConnectionString = identityUIOptions.Database?.ConnectionString }; services.Configure <DatabaseOptions>(options => { options.Type = databaseOptions.Type; options.ConnectionString = databaseOptions.ConnectionString; }); services.Configure <EmailSenderOptions>(options => { options.Ip = identityUIOptions.EmailSender?.Ip; options.Port = identityUIOptions.EmailSender?.Port ?? -1; options.UserName = identityUIOptions.EmailSender?.UserName; options.Password = identityUIOptions.EmailSender?.Password; options.SenderEmail = identityUIOptions.EmailSender?.SenderName; options.SenderEmail = identityUIOptions.EmailSender?.SenderEmail; options.SenderDisplayName = identityUIOptions.EmailSender?.SenderDisplayName; options.UseSSL = identityUIOptions.EmailSender?.UseSSL ?? false; }); IdentityUIEndpoints identityManagementEndpoints = new IdentityUIEndpoints(); endpointAction?.Invoke(identityManagementEndpoints); if (!identityManagementEndpoints.UseEmailSender.HasValue) { if (identityUIOptions.EmailSender == null || string.IsNullOrEmpty(identityUIOptions.EmailSender.Ip)) { identityManagementEndpoints.UseEmailSender = false; } else { identityManagementEndpoints.UseEmailSender = true; } } services.Configure <IdentityUIEndpoints>(options => { options.Home = identityManagementEndpoints.Home; options.Login = identityManagementEndpoints.Login; options.Logout = identityManagementEndpoints.Logout; options.AccessDenied = identityManagementEndpoints.AccessDenied; options.Manage = identityManagementEndpoints.Manage; options.ConfirmeEmail = identityManagementEndpoints.ConfirmeEmail; options.ResetPassword = identityManagementEndpoints.ResetPassword; options.AcceptInvite = identityManagementEndpoints.AcceptInvite; options.ProfileImage = identityManagementEndpoints.ProfileImage; options.AdminLogo = identityManagementEndpoints.AdminLogo; options.AccountSettingsLogo = identityManagementEndpoints.AccountSettingsLogo; options.RegisterEnabled = identityManagementEndpoints.RegisterEnabled; options.GroupRegistrationEnabled = identityManagementEndpoints.GroupRegistrationEnabled; options.AuthenticatorIssuer = identityManagementEndpoints.AuthenticatorIssuer; options.UseEmailSender = identityManagementEndpoints.UseEmailSender; options.UseSmsGateway = identityManagementEndpoints.UseSmsGateway; options.InviteValidForTimeSpan = identityManagementEndpoints.InviteValidForTimeSpan; options.BypassTwoFactorOnExternalLogin = identityManagementEndpoints.BypassTwoFactorOnExternalLogin; options.UseEmailAsUsername = identityManagementEndpoints.UseEmailAsUsername; options.ShowAuditToUser = identityManagementEndpoints.ShowAuditToUser; options.CanChangeGroupName = identityManagementEndpoints.CanChangeGroupName; options.CanRemoveGroup = identityManagementEndpoints.CanRemoveGroup; options.CanRemoveUser = identityManagementEndpoints.CanRemoveUser; options.AllowImpersonation = identityManagementEndpoints.AllowImpersonation; }); IdentityUIServicesBuilder builder = new IdentityUIServicesBuilder(services, identityManagementEndpoints, databaseOptions, configuration); builder.Services.AddScoped <IEmailSender, NullEmailSender>(); builder.Services.AddScoped <ISmsSender, NullSmsSender>(); builder.Services.AddScoped <IReleaseManagement, ReleaseManagement>(); builder.Services.AddAudit(); builder.Services.AddTransient <IAuditDbContext, IdentityDbContext>(); services.AddScoped <Audit.Services.IAuditSubjectDataService>(x => { Microsoft.Extensions.Options.IOptions <Audit.Models.AuditOptions> auditOptions = x.GetRequiredService <Microsoft.Extensions.Options.IOptions <Audit.Models.AuditOptions> >(); Microsoft.Extensions.Options.IOptions <IdentityUIClaimOptions> identityUIClaimOptions = x.GetRequiredService <Microsoft.Extensions.Options.IOptions <IdentityUIClaimOptions> >(); Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor = x.GetRequiredService <Microsoft.AspNetCore.Http.IHttpContextAccessor>(); IIdentityUIUserInfoService identityUIUserInfoService = x.GetRequiredService <IIdentityUIUserInfoService>(); if (httpContextAccessor.HttpContext != null) { return(new IdentityUIAuditSubjectService(httpContextAccessor, identityUIUserInfoService, auditOptions, identityUIClaimOptions)); } Audit.Services.IBackgroundServiceContextAccessor backgroundServiceContextAccessor = x.GetRequiredService <Audit.Services.IBackgroundServiceContextAccessor>(); if (backgroundServiceContextAccessor.BackgroundServiceContext != null) { return(new Audit.Services.BackgroundServiceAuditSubjectDataService(backgroundServiceContextAccessor)); } return(new Audit.Services.DefaultAuditSubjectService(auditOptions)); }); return(builder); }
public CredentialsDataService(UserManager <AppUserEntity> userManager, IIdentityUIUserInfoService identityUIUserInfoService) { _userManager = userManager; _identityUIUserInfoService = identityUIUserInfoService; }
public GroupController(IGroupDataService groupDataService, IGroupService groupService, IIdentityUIUserInfoService identityUIUserInfoService) { _groupDataService = groupDataService; _groupService = groupService; _identityUIUserInfoService = identityUIUserInfoService; }