public PermissionValidateHandler(IOptionsMonitor <AdminOptions> optionsAccessor, IAccountService accountService, ILoginInfo loginInfo, SystemConfigModel systemConfig) { _options = optionsAccessor.CurrentValue; _accountService = accountService; _loginInfo = loginInfo; _systemConfig = systemConfig; }
public PermissionValidateHandler(IOptionsMonitor <AdminOptions> optionsAccessor, IAccountService accountService, ILoginInfo loginInfo, ISystemService systemService) { _options = optionsAccessor.CurrentValue; _accountService = accountService; _loginInfo = loginInfo; _systemConfig = systemService.GetConfig().Result.Data; }
public AuditingFilter(IOptionsMonitor <AdminOptions> optionsAccessor, IAuditInfoService auditInfoService, LoginInfo loginInfo, ISystemService systemService) { _options = optionsAccessor.CurrentValue; _auditInfoService = auditInfoService; _loginInfo = loginInfo; _systemService = systemService; }
public NoteController(IOptions <AdminOptions> option, ILogger <NoteController> logger) { _logger = logger; _options = option.Value; _request = new NoteGrpcRequest(); _noteGrpcService = GrpcClientHelper.CreateClient <INoteGrpcService>(_options.ApiLocalEndpoint); }
public BlogController( IOptions <AdminOptions> options, ILogger <BlogController> logger) { _logger = logger; _options = options.Value; _blogGrpcRequest = new BlogGrpcRequest(); _blogGrpcService = GrpcClientHelper.CreateClient <IBlogGrpcService>(options.Value.ApiLocalEndpoint); }
public InsertAdminRepository(IOptions <AdminOptions> options) { if (options == null) { throw new ArgumentNullException(nameof(options)); } _options = options.Value; }
public SystemController(ISystemService systemService, IOptionsMonitor <AdminOptions> optionsMonitor, FileUploadHelper fileUploadHelper, PermissionHelper permissionHelper, MvcHelper mvcHelper) { _systemService = systemService; _fileUploadHelper = fileUploadHelper; _permissionHelper = permissionHelper; _mvcHelper = mvcHelper; _options = optionsMonitor.CurrentValue; }
public AuthController(IServiceProvider provider, IOptions <AdminOptions> adminOptions, ITokenGenerator tokenGenerator, IUsersRepository repository) : base(provider) { _adminOptions = adminOptions.Value; _tokenGenerator = tokenGenerator; _usersRepo = repository; }
public RecipesController( IRecipeService recipeService, IOptions <PagingOptions> defaultPagingOptionsWrapper, IOptions <AdminOptions> adminOptions) { this.recipeService = recipeService; defaultPagingOptions = defaultPagingOptionsWrapper?.Value ?? new PagingOptions(); this.adminOptions = adminOptions?.Value ?? new AdminOptions(); }
public PermissionService(IPermissionRepository permissionRepository, AdminDbContext dbContext, IModuleRepository moduleRepository, SystemConfigModel systemConfig, ICacheHandler cacheHandler, ILogger <PermissionService> logger, AdminOptions options) { _repository = permissionRepository; _dbContext = dbContext; _moduleRepository = moduleRepository; _systemConfig = systemConfig; _cacheHandler = cacheHandler; _logger = logger; _options = options; }
public ModuleService(IModuleRepository repository, IModuleCollection moduleCollection, AdminDbContext dbContext, ILogger <ModuleService> logger, IModuleOptionsEngine moduleOptionsContainer, IAuditInfoRepository auditInfoRepository, AdminOptions options) { _repository = repository; _moduleCollection = moduleCollection; _dbContext = dbContext; _logger = logger; _moduleOptionsContainer = moduleOptionsContainer; _auditInfoRepository = auditInfoRepository; _options = options; }
public StartupSetup(ILogger <StartupSetup> logger, IOptions <VideoServerOptions> options, VideoCdnDbContext dbContext, UserManager <VideoCdnUser> userManager, RoleManager <IdentityRole <int> > roleManager, IOptions <AdminOptions> adminOptions) { this.logger = logger; this.options = options.Value; this.dbContext = dbContext; this.userManager = userManager; this.roleManager = roleManager; this.adminOptions = adminOptions.Value; }
public ConsentController( IIdentityServerInteractionService interaction, IClientStore clientStore, IResourceStore resourceStore, AdminOptions options, ILoggerFactory loggerFactory) : base(loggerFactory) { _interaction = interaction; _clientStore = clientStore; _resourceStore = resourceStore; _options = options; }
public static IApplicationBuilder SeedIdentityData(this IApplicationBuilder app, UserManager <IdentityUser> userManager, RoleManager <IdentityRole> roleManager, IConfiguration configuration) { AdminOptions options = configuration.GetSection("DefaultAdmin").Get <AdminOptions>(); SeedRoles(roleManager); SeedUsers(userManager, options); return(app); }
public ConsentController( IIdentityServerInteractionService interaction, IClientStore clientStore, IResourceStore resourceStore, ILogger <ConsentController> logger, AdminOptions options) { _interaction = interaction; _clientStore = clientStore; _resourceStore = resourceStore; _logger = logger; _options = options; }
public UserController(UserManager <User> userManager, RoleManager <Role> roleManager, IDbContext dbContext, IServiceProvider serviceProvider, AdminOptions options, ILoggerFactory loggerFactory) : base(loggerFactory) { _userManager = userManager; _dbContext = dbContext; _serviceProvider = serviceProvider; _roleManager = roleManager; _options = options; }
public AccountService(ICacheHandler cache, IMapper mapper, IAccountRepository accountRepository, IAccountRoleRepository accountRoleRepository, IRoleRepository roleRepository, IPermissionRepository permissionRepository, IAccountConfigRepository accountConfigRepository, AdminDbContext dbContext, IPasswordHandler passwordHandler, AdminOptions options) { _cache = cache; _mapper = mapper; _accountRepository = accountRepository; _accountRoleRepository = accountRoleRepository; _roleRepository = roleRepository; _permissionRepository = permissionRepository; _accountConfigRepository = accountConfigRepository; _dbContext = dbContext; _passwordHandler = passwordHandler; _options = options; }
public ContentTypesAdminNodeNavigationBuilder( IOptions <AdminOptions> adminOptions, IContentDefinitionManager contentDefinitionManager, LinkGenerator linkGenerator, IHttpContextAccessor httpContextAccessor, ILogger <ContentTypesAdminNodeNavigationBuilder> logger) { _adminOptions = adminOptions.Value; _contentDefinitionManager = contentDefinitionManager; _linkGenerator = linkGenerator; _httpContextAccessor = httpContextAccessor; _logger = logger; }
public ImpersonationController( SignInManager <IUser> signInManager, UserManager <IUser> userManager, IAuthorizationService authorizationService, IOptions <AdminOptions> adminOptions, ILogger <ImpersonationController> logger, IStringLocalizer <ImpersonationController> stringLocalizer) { _signInManager = signInManager; _userManager = userManager; _authorizationService = authorizationService; _adminOptions = adminOptions.Value; _logger = logger; S = stringLocalizer; }
/// <summary> /// Initializes a new instance of <see cref="ShareController"/>. /// </summary> public ShareController( IOptions <AdminOptions> adminOptions, ApplicationDbContext context, IStringLocalizer <ErrorMessages> errorLocalizer, IStringLocalizer <EmailMessages> emailLocalizer, RoleManager <IdentityRole> roleManager, UserManager <ApplicationUser> userManager) { _adminOptions = adminOptions.Value; _context = context; _errorLocalizer = errorLocalizer; _emailLocalizer = emailLocalizer; _roleManager = roleManager; _userManager = userManager; }
private static void SeedUsers(UserManager <IdentityUser> userManager, AdminOptions adminOptions) { if (userManager.FindByNameAsync(adminOptions.Email).Result == null) { IdentityUser identityUser = new IdentityUser { Email = adminOptions.Email, UserName = adminOptions.Email }; IdentityResult result = userManager.CreateAsync(identityUser, adminOptions.Password).Result; if (result.Succeeded) { userManager.AddToRoleAsync(identityUser, RoleNames.Admin).Wait(); } } }
public AccountController( UserManager <User> userManager, SignInManager <User> signInManager, IIdentityServerInteractionService interaction, IClientStore clientStore, IAuthenticationSchemeProvider schemeProvider, IEventService events, AdminOptions options) { _userManager = userManager; _signInManager = signInManager; _interaction = interaction; _clientStore = clientStore; _schemeProvider = schemeProvider; _events = events; _options = options; }
/// <summary> /// Initializes a new instance of <see cref="AccountController"/>. /// </summary> public AccountController( IOptions <AdminOptions> adminOptions, IEmailSender emailSender, IStringLocalizer <ErrorMessages> errorLocalizer, ILogger <AccountController> logger, IStringLocalizer <EmailMessages> emailLocalizer, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager) { _adminOptions = adminOptions.Value; _emailSender = emailSender; _errorLocalizer = errorLocalizer; _logger = logger; _emailLocalizer = emailLocalizer; _signInManager = signInManager; _userManager = userManager; }
public AuthService(DrawingHelper drawingHelper, ICacheHandler cacheHandler, SystemConfigModel systemConfig, IAccountRepository accountRepository, AdminDbContext dbContext, IAccountAuthInfoRepository authInfoRepository, IPasswordHandler passwordHandler, IAccountConfigRepository configRepository, IServiceProvider serviceProvider, IMenuRepository menuRepository, IMapper mapper, IButtonRepository buttonRepository, ILoginInfo loginInfo, AdminOptions options) { _drawingHelper = drawingHelper; _cacheHandler = cacheHandler; _systemConfig = systemConfig; _accountRepository = accountRepository; _dbContext = dbContext; _authInfoRepository = authInfoRepository; _passwordHandler = passwordHandler; _configRepository = configRepository; _serviceProvider = serviceProvider; _menuRepository = menuRepository; _mapper = mapper; _buttonRepository = buttonRepository; _loginInfo = loginInfo; _options = options; }
/// <summary> /// Seeds the framework's database with core data. /// </summary> public static void Initialize(IServiceProvider provider, VueCoreFrameworkDbContext context) { using (var serviceScope = provider.GetService <IServiceScopeFactory>().CreateScope()) { context.Database.Migrate(); var roleManager = serviceScope.ServiceProvider.GetRequiredService <RoleManager <IdentityRole> >(); if (!context.Roles.Any(r => r.Name == CustomRoles.SiteAdmin)) { var admin = new IdentityRole(CustomRoles.SiteAdmin); roleManager.CreateAsync(admin).Wait(); roleManager.AddClaimAsync(admin, new Claim(CustomClaimTypes.PermissionGroupSiteAdmin, CustomClaimTypes.PermissionAll)).Wait(); roleManager.AddClaimAsync(admin, new Claim(CustomClaimTypes.PermissionDataAll, CustomClaimTypes.PermissionAll)).Wait(); context.SaveChanges(); } if (!context.Roles.Any(r => r.Name == CustomRoles.Admin)) { var admin = new IdentityRole(CustomRoles.Admin); roleManager.CreateAsync(admin).Wait(); roleManager.AddClaimAsync(admin, new Claim(CustomClaimTypes.PermissionGroupAdmin, CustomClaimTypes.PermissionAll)).Wait(); roleManager.AddClaimAsync(admin, new Claim(CustomClaimTypes.PermissionDataAll, CustomClaimTypes.PermissionAll)).Wait(); context.SaveChanges(); } var siteAdminRole = context.Roles.FirstOrDefault(r => r.Name == CustomRoles.SiteAdmin); if (!context.UserRoles.Any(r => r.RoleId == siteAdminRole.Id)) { var userManager = serviceScope.ServiceProvider.GetRequiredService <UserManager <ApplicationUser> >(); var adminOptions = new AdminOptions(); serviceScope.ServiceProvider.GetRequiredService <IConfigureOptions <AdminOptions> >().Configure(adminOptions); var user = context.Users.FirstOrDefault(u => u.Email == adminOptions.AdminEmailAddress); if (user == null) { user = new ApplicationUser { UserName = "******", Email = adminOptions.AdminEmailAddress }; userManager.CreateAsync(user, adminOptions.AdminPassword).Wait(); userManager.Users.FirstOrDefault().EmailConfirmed = true; userManager.UpdateAsync(user).Wait(); } userManager.AddToRoleAsync(user, CustomRoles.SiteAdmin).Wait(); userManager.AddToRoleAsync(user, CustomRoles.Admin).Wait(); context.SaveChanges(); } } }
public PagedListResultOfArrayOfUserDataVUqw3SxC exportUsers(AdminOptions adminOptions) { String authToken = client.AuthenticateUser(adminOptions.getUserName(), adminOptions.getPassword()).ResultData; ServiceOperationResultOfPagedListResultOfArrayOfUserDataVUqw3SxCVUqw3SxC serviceOperationResult = client.GetUsers(authToken, adminOptions.getProvider(), adminOptions.getPageNumber(), adminOptions.getPageSize(), adminOptions.getSortField(), adminOptions.getSortAscending(), adminOptions.getFilterField(), adminOptions.getFilterValue()); if (!serviceOperationResult.CallSuccess) { throw new System.ArgumentException(); } return getServiceOperationResult(serviceOperationResult); }
/// <summary> Constructor. </summary> /// <param name="userManager"> Manager for user. </param> /// <param name="signInManager"> Manager for sign in. </param> /// <param name="emailSender"> The email sender. </param> /// <param name="loggerFactory"> The logger factory. </param> /// <param name="dataService"> The data service. </param> /// <param name="adminOptions"> Options for controlling the admin. </param> /// <param name="localizer"> The localizer. </param> /// <param name="localizerFactory"> The localizer factory. </param> /// <param name="identityDataService"> The identity data service. </param> /// <param name="applicationOptions"> Options for controlling the application. </param> public AccountController( UserManager <IdentityUserEntity> userManager, SignInManager <IdentityUserEntity> signInManager, ITemplatingMailService emailSender, ILoggerFactory loggerFactory, IIdentityDataService dataService, AdminOptions adminOptions, IStringLocalizer <AccountResource> localizer, IStringLocalizerFactory localizerFactory, IIdentityDataService identityDataService, ApplicationOptions applicationOptions) { _userManager = userManager; _signInManager = signInManager; _emailSender = emailSender; _logger = loggerFactory.CreateLogger <AccountController>(); _adminOptions = adminOptions; _localizer = localizer; _localizerFactory = localizerFactory; _identityDataService = identityDataService; _applicationOptions = applicationOptions; }
private static void SeedAdminUser(UserManager <IdentityUser> userManager, AdminOptions options) { var foundUser = userManager.FindByNameAsync(options.UserName).Result; if (foundUser == null) { var newUser = new IdentityUser() { UserName = options.UserName, Email = options.Email } ; var result = userManager.CreateAsync(newUser, options.Password).Result; if (result.Succeeded) { userManager.AddToRoleAsync(newUser, Enum.GetName(typeof(Role), Role.Admin)).GetAwaiter().GetResult(); } } }
public CustomSetupController( IShellHost shellHost, ISetupService setupService, ShellSettings shellSettings, IClock clock, ILogger <CustomSetupController> logger, IStringLocalizer <CustomSetupController> localizer, IEmailAddressValidator emailAddressValidator, IConfiguration configuration, IOptions <AdminOptions> adminOptions, IShellSettingsManager shellSettingsManager) { _shellHost = shellHost; _setupService = setupService; _shellSettings = shellSettings; _clock = clock; _logger = logger; S = localizer; _emailAddressValidator = emailAddressValidator; _configuration = configuration; _adminOptions = adminOptions.Value; _shellSettingsManager = shellSettingsManager; }
/// <summary> /// Initializes a new instance of <see cref="ManageController"/>. /// </summary> public ManageController( IOptions <AdminOptions> adminOptions, Sample.Data.ApplicationDbContext context, IEmailSender emailSender, IStringLocalizer <ErrorMessages> errorLocalizer, IOptions <RequestLocalizationOptions> localizationOptions, ILogger <ManageController> logger, IStringLocalizer <EmailMessages> emailLocalizer, RoleManager <IdentityRole> roleManager, SignInManager <ApplicationUser> signInManager, UserManager <ApplicationUser> userManager) { _adminOptions = adminOptions.Value; _context = context; _emailSender = emailSender; _errorLocalizer = errorLocalizer; _localizationOptions = localizationOptions.Value; _logger = logger; _emailLocalizer = emailLocalizer; _roleManager = roleManager; _signInManager = signInManager; _userManager = userManager; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, RoleManager <IdentityRole> roleManager, UserManager <IdentityUser> userManager) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); app.UseWebAssemblyDebugging(); } else { app.UseExceptionHandler("/Error"); // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts. app.UseHsts(); } app.UseHttpsRedirection(); app.UseBlazorFrameworkFiles(); app.UseStaticFiles(); app.UseRouting(); app.UseAuthentication(); app.UseIdentityServer(); app.UseAuthorization(); // Create and bind options to configuration that will be used to seed data AdminOptions options = new AdminOptions(); Configuration.GetSection("Admin").Bind(options); OregonTrailDBInitializer.SeedIdentity(roleManager, userManager, options); app.UseEndpoints(endpoints => { endpoints.MapRazorPages(); // razor pages for authentication are mapped to the server endpoints.MapControllers(); endpoints.MapFallbackToFile("index.html"); }); }