public TestHelper() : base(typeof(TestHelper).Assembly) { var httpContext = new DefaultHttpContext(); httpContext.Connection.RemoteIpAddress = IPAddress.Parse("127.0.0.1"); _httpContextAccessor = Mock.Of <IHttpContextAccessor>(x => x.HttpContext == httpContext); _ipResolver = new AspNetCoreIpResolver(_httpContextAccessor); string contentRoot = Assembly.GetExecutingAssembly().GetRootDirectorySafe(); // The mock for IWebHostEnvironment has caused a good few issues. // We can UseContentRoot, UseWebRoot etc on the host builder instead. // possibly going down rabbit holes though as would need to cleanup all usages of // GetHostingEnvironment & GetWebHostEnvironment. var hostEnvironment = new Mock <IWebHostEnvironment>(); // This must be the assembly name for the WebApplicationFactory to work. hostEnvironment.Setup(x => x.ApplicationName).Returns(GetType().Assembly.GetName().Name); hostEnvironment.Setup(x => x.ContentRootPath).Returns(() => contentRoot); hostEnvironment.Setup(x => x.ContentRootFileProvider).Returns(() => new PhysicalFileProvider(contentRoot)); hostEnvironment.Setup(x => x.WebRootPath).Returns(() => WorkingDirectory); hostEnvironment.Setup(x => x.WebRootFileProvider).Returns(() => new PhysicalFileProvider(WorkingDirectory)); hostEnvironment.Setup(x => x.EnvironmentName).Returns("Tests"); // We also need to expose it as the obsolete interface since netcore's WebApplicationFactory casts it. hostEnvironment.As <Microsoft.AspNetCore.Hosting.IHostingEnvironment>(); _hostEnvironment = hostEnvironment.Object; _hostingLifetime = new AspNetCoreApplicationShutdownRegistry(Mock.Of <IHostApplicationLifetime>()); ConsoleLoggerFactory = LoggerFactory.Create(builder => builder.AddConsole()); ProfilingLogger = new ProfilingLogger(ConsoleLoggerFactory.CreateLogger <ProfilingLogger>(), Profiler); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigureBackOfficeCookieOptions" /> class. /// </summary> /// <param name="serviceProvider">The <see cref="IServiceProvider" /></param> /// <param name="umbracoContextAccessor">The <see cref="IUmbracoContextAccessor" /></param> /// <param name="securitySettings">The <see cref="SecuritySettings" /> options</param> /// <param name="globalSettings">The <see cref="GlobalSettings" /> options</param> /// <param name="hostingEnvironment">The <see cref="IHostingEnvironment" /></param> /// <param name="runtimeState">The <see cref="IRuntimeState" /></param> /// <param name="dataProtection">The <see cref="IDataProtectionProvider" /></param> /// <param name="userService">The <see cref="IUserService" /></param> /// <param name="ipResolver">The <see cref="IIpResolver" /></param> /// <param name="systemClock">The <see cref="ISystemClock" /></param> /// <param name="umbracoRequestPaths">The <see cref="UmbracoRequestPaths"/></param> /// <param name="basicAuthService">The <see cref="IBasicAuthService"/></param> public ConfigureBackOfficeCookieOptions( IServiceProvider serviceProvider, IUmbracoContextAccessor umbracoContextAccessor, IOptions <SecuritySettings> securitySettings, IOptions <GlobalSettings> globalSettings, IHostingEnvironment hostingEnvironment, IRuntimeState runtimeState, IDataProtectionProvider dataProtection, IUserService userService, IIpResolver ipResolver, ISystemClock systemClock, UmbracoRequestPaths umbracoRequestPaths, IBasicAuthService basicAuthService) { _serviceProvider = serviceProvider; _umbracoContextAccessor = umbracoContextAccessor; _securitySettings = securitySettings.Value; _globalSettings = globalSettings.Value; _hostingEnvironment = hostingEnvironment; _runtimeState = runtimeState; _dataProtection = dataProtection; _userService = userService; _ipResolver = ipResolver; _systemClock = systemClock; _umbracoRequestPaths = umbracoRequestPaths; _basicAuthService = basicAuthService; }
public EthereumRunner(IRpcModuleProvider rpcModuleProvider, IConfigProvider configurationProvider, ILogManager logManager, IGrpcServer grpcServer, INdmConsumerChannelManager ndmConsumerChannelManager, INdmDataPublisher ndmDataPublisher, INdmInitializer ndmInitializer, IWebSocketsManager webSocketsManager, IJsonSerializer ethereumJsonSerializer) { _logManager = logManager ?? throw new ArgumentNullException(nameof(logManager)); _grpcServer = grpcServer; _ndmConsumerChannelManager = ndmConsumerChannelManager; _ndmDataPublisher = ndmDataPublisher; _ndmInitializer = ndmInitializer; _webSocketsManager = webSocketsManager; _ethereumJsonSerializer = ethereumJsonSerializer; _logger = _logManager.GetClassLogger(); InitRlp(); _configProvider = configurationProvider ?? throw new ArgumentNullException(nameof(configurationProvider)); _rpcModuleProvider = rpcModuleProvider ?? throw new ArgumentNullException(nameof(rpcModuleProvider)); _initConfig = configurationProvider.GetConfig <IInitConfig>(); _txPoolConfig = configurationProvider.GetConfig <ITxPoolConfig>(); _perfService = new PerfService(_logManager); _networkConfig = _configProvider.GetConfig <INetworkConfig>(); _ipResolver = new IpResolver(_networkConfig, _logManager); _networkConfig.ExternalIp = _ipResolver.ExternalIp.ToString(); _networkConfig.LocalIp = _ipResolver.LocalIp.ToString(); }
public MemberManager( IIpResolver ipResolver, IMemberUserStore store, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <MemberIdentityUser> passwordHasher, IEnumerable <IUserValidator <MemberIdentityUser> > userValidators, IEnumerable <IPasswordValidator <MemberIdentityUser> > passwordValidators, IdentityErrorDescriber errors, IServiceProvider services, ILogger <UserManager <MemberIdentityUser> > logger, IOptionsSnapshot <MemberPasswordConfigurationSettings> passwordConfiguration, IPublicAccessService publicAccessService, IHttpContextAccessor httpContextAccessor) : base( ipResolver, store, optionsAccessor, passwordHasher, userValidators, passwordValidators, errors, services, logger, passwordConfiguration) { _store = store; _publicAccessService = publicAccessService; _httpContextAccessor = httpContextAccessor; }
public BackOfficeUserManager( IIpResolver ipResolver, IUserStore <BackOfficeIdentityUser> store, IOptions <BackOfficeIdentityOptions> optionsAccessor, IPasswordHasher <BackOfficeIdentityUser> passwordHasher, IEnumerable <IUserValidator <BackOfficeIdentityUser> > userValidators, IEnumerable <IPasswordValidator <BackOfficeIdentityUser> > passwordValidators, BackOfficeErrorDescriber errors, IServiceProvider services, IHttpContextAccessor httpContextAccessor, ILogger <UserManager <BackOfficeIdentityUser> > logger, IOptions <UserPasswordConfigurationSettings> passwordConfiguration, IEventAggregator eventAggregator, IBackOfficeUserPasswordChecker backOfficeUserPasswordChecker) : base( ipResolver, store, optionsAccessor, passwordHasher, userValidators, passwordValidators, errors, services, logger, passwordConfiguration) { _httpContextAccessor = httpContextAccessor; _eventAggregator = eventAggregator; _backOfficeUserPasswordChecker = backOfficeUserPasswordChecker; }
public HostInfoService( IHostInfoReader reader, IHostInfoWriter writer, IIpResolver resolver, ILoggerFacade loggerFacade) { this.reader = reader; this.writer = writer; this.resolver = resolver; this.loggerFacade = loggerFacade; }
/// <summary> /// Initialize ClientTracker instance /// </summary> /// <param name="collectorUrl">required, set from config</param> /// <param name="sharedSecretKey">required, set from config</param> /// <param name="deviceId">required</param> /// <param name="clientId">required</param> /// <param name="systemVersion">required</param> /// <param name="productVersion"></param> /// <param name="system"></param> /// <param name="productGitHash"></param> /// <param name="queueSize">default: 20</param> /// <param name="queueRetentionMinutes">default: 1440 (minutes = 24 hours)</param> public ClientTracker( string collectorUrl, string sharedSecretKey, string deviceId, string clientId, string systemVersion, string productVersion, string system, string productGitHash, int queueSize, int queueRetentionMinutes, IPersistentStorage persistentStorage, IEventPublisher eventPublisher, IIpResolver ipResolver ) { collectorUrl.Check(s => !string.IsNullOrWhiteSpace(s), "collectorUrl"); sharedSecretKey.Check(s => !string.IsNullOrWhiteSpace(s), "sharedSecretKey"); deviceId.Check(s => !string.IsNullOrWhiteSpace(s), "deviceId"); clientId.Check(s => !string.IsNullOrWhiteSpace(s), "clientId"); systemVersion.Check(s => !string.IsNullOrWhiteSpace(s), "systemVersion"); this._collectorUrl = collectorUrl; this._sharedSecretKey = sharedSecretKey; this._deviceIdHash = HashUtil.HashSha256ToString(StringEncoding.GetBytes(deviceId)); this._clientId = clientId; this._systemVersion = systemVersion; this._productVersion = productVersion; this._system = system; this._productGitHash = productGitHash; this._queueSize = Math.Max(0, queueSize); this._queueRetentionMinutes = Math.Max(0, queueRetentionMinutes); this._persistentStorage = persistentStorage; this._eventPublisher = eventPublisher; this._ipResolver = ipResolver; }
/// <summary> /// Initializes a new instance of the <see cref="UmbracoUserManager{T, TPasswordConfig}"/> class. /// </summary> public UmbracoUserManager( IIpResolver ipResolver, IUserStore <TUser> store, IOptions <IdentityOptions> optionsAccessor, IPasswordHasher <TUser> passwordHasher, IEnumerable <IUserValidator <TUser> > userValidators, IEnumerable <IPasswordValidator <TUser> > passwordValidators, IdentityErrorDescriber errors, IServiceProvider services, ILogger <UserManager <TUser> > logger, IOptions <TPasswordConfig> passwordConfiguration) : base(store, optionsAccessor, passwordHasher, userValidators, passwordValidators, new NoopLookupNormalizer(), errors, services, logger) { IpResolver = ipResolver ?? throw new ArgumentNullException(nameof(ipResolver)); PasswordConfiguration = passwordConfiguration.Value ?? throw new ArgumentNullException(nameof(passwordConfiguration)); }
public AuditNotificationsHandler( IAuditService auditService, IUserService userService, IEntityService entityService, IIpResolver ipResolver, IOptions <GlobalSettings> globalSettings, IBackOfficeSecurityAccessor backOfficeSecurityAccessor, IMemberService memberService) { _auditService = auditService; _userService = userService; _entityService = entityService; _ipResolver = ipResolver; _backOfficeSecurityAccessor = backOfficeSecurityAccessor; _memberService = memberService; _globalSettings = globalSettings.Value; }
public AuthenticationController( IBackOfficeSecurityAccessor backofficeSecurityAccessor, IBackOfficeUserManager backOfficeUserManager, IBackOfficeSignInManager signInManager, IUserService userService, ILocalizedTextService textService, IUmbracoMapper umbracoMapper, IOptionsSnapshot <GlobalSettings> globalSettings, IOptionsSnapshot <SecuritySettings> securitySettings, ILogger <AuthenticationController> logger, IIpResolver ipResolver, IOptionsSnapshot <UserPasswordConfigurationSettings> passwordConfiguration, IEmailSender emailSender, ISmsSender smsSender, IHostingEnvironment hostingEnvironment, LinkGenerator linkGenerator, IBackOfficeExternalLoginProviders externalAuthenticationOptions, IBackOfficeTwoFactorOptions backOfficeTwoFactorOptions, IHttpContextAccessor httpContextAccessor, IOptions <WebRoutingSettings> webRoutingSettings, ITwoFactorLoginService twoFactorLoginService) { _backofficeSecurityAccessor = backofficeSecurityAccessor; _userManager = backOfficeUserManager; _signInManager = signInManager; _userService = userService; _textService = textService; _umbracoMapper = umbracoMapper; _globalSettings = globalSettings.Value; _securitySettings = securitySettings.Value; _logger = logger; _ipResolver = ipResolver; _passwordConfiguration = passwordConfiguration.Value; _emailSender = emailSender; _smsSender = smsSender; _hostingEnvironment = hostingEnvironment; _linkGenerator = linkGenerator; _externalAuthenticationOptions = externalAuthenticationOptions; _backOfficeTwoFactorOptions = backOfficeTwoFactorOptions; _httpContextAccessor = httpContextAccessor; _webRoutingSettings = webRoutingSettings.Value; _twoFactorLoginService = twoFactorLoginService; }
public AuthenticationController( IBackOfficeSecurityAccessor backofficeSecurityAccessor, IBackOfficeUserManager backOfficeUserManager, IBackOfficeSignInManager signInManager, IUserService userService, ILocalizedTextService textService, IUmbracoMapper umbracoMapper, IOptions <GlobalSettings> globalSettings, IOptions <SecuritySettings> securitySettings, ILogger <AuthenticationController> logger, IIpResolver ipResolver, IOptions <UserPasswordConfigurationSettings> passwordConfiguration, IEmailSender emailSender, ISmsSender smsSender, IHostingEnvironment hostingEnvironment, LinkGenerator linkGenerator, IBackOfficeExternalLoginProviders externalAuthenticationOptions, IBackOfficeTwoFactorOptions backOfficeTwoFactorOptions, IHttpContextAccessor httpContextAccessor, IOptions <WebRoutingSettings> webRoutingSettings) : this( backofficeSecurityAccessor, backOfficeUserManager, signInManager, userService, textService, umbracoMapper, globalSettings, securitySettings, logger, ipResolver, passwordConfiguration, emailSender, smsSender, hostingEnvironment, linkGenerator, externalAuthenticationOptions, backOfficeTwoFactorOptions, StaticServiceProvider.Instance.GetRequiredService <IHttpContextAccessor>(), StaticServiceProvider.Instance.GetRequiredService <IOptions <WebRoutingSettings> >(), StaticServiceProvider.Instance.GetRequiredService <ITwoFactorLoginService>()) { }
public IpResolverLogDecorator(IIpResolver resolver, ILoggerFacade logger) { this.resolver = resolver; this.logger = logger; }
/// <summary> /// Initialize ClientTracker instance /// </summary> /// <param name="collectorUrl">required, set from config</param> /// <param name="sharedSecretKey">required, set from config</param> /// <param name="deviceId">required</param> /// <param name="clientId">required</param> /// <param name="systemVersion">required</param> /// <param name="productVersion"></param> /// <param name="system"></param> /// <param name="productGitHash"></param> /// <param name="queueSize">default: 20</param> /// <param name="queueRetentionMinutes">default: 1440 (minutes = 24 hours)</param> public ClientTracker( string collectorUrl, string sharedSecretKey, string deviceId, string clientId, string systemVersion, string productVersion, string system, string productGitHash, int queueSize, int queueRetentionMinutes, IPersistentStorage persistentStorage, IEventPublisher eventPublisher, IIpResolver ipResolver ) { collectorUrl.Check(s => !string.IsNullOrWhiteSpace(s), "collectorUrl"); sharedSecretKey.Check(s => !string.IsNullOrWhiteSpace(s), "sharedSecretKey"); deviceId.Check(s => !string.IsNullOrWhiteSpace(s), "deviceId"); clientId.Check(s => !string.IsNullOrWhiteSpace(s), "clientId"); systemVersion.Check(s => !string.IsNullOrWhiteSpace(s), "systemVersion"); this._collectorUrl = collectorUrl; this._sharedSecretKey = sharedSecretKey; this._deviceIdHash = HashUtil.HashSha256ToString(StringEncoding.GetBytes(deviceId)); this._clientId = clientId; this._systemVersion = systemVersion; this._productVersion = productVersion; this._system = system; this._productGitHash = productGitHash; this._queueSize = Math.Max(0, queueSize); this._queueRetentionMinutes = Math.Max(0, queueRetentionMinutes); this._persistentStorage = persistentStorage; this._eventPublisher = eventPublisher; this._ipResolver = ipResolver; }