public static void AddAuthenticator(this IServiceCollection services, AuthenticatorServiceOptions configureOptions) { configureOptions.CheckArgumentNull(nameof(configureOptions)); services.TryAddSingleton(Options.Create(configureOptions)); services.TryAddSingleton <ISystemTime, DefaultSystemTime>(); services.TryAddSingleton <IAuthenticatorService, AuthenticatorService>(); }
public static void AddAuthenticator(this IServiceCollection services, Action <AuthenticatorServiceOptions> configuration) { configuration.CheckArgumentNull(nameof(configuration)); var configureOptions = new AuthenticatorServiceOptions(); configuration(configureOptions); AddAuthenticator(services, configureOptions); }
public AuthenticatorService(IOptions <AuthenticatorServiceOptions> options, ISystemTime systemTime) { options.CheckArgumentNull(nameof(options)); systemTime.CheckArgumentNull(nameof(systemTime)); options.Value.Issuer.CheckMandatoryOption(nameof(options.Value.Issuer)); if (options.Value.NumberOfDigits < 6 || options.Value.NumberOfDigits > 8) { throw new ArgumentException(Resources.Exception_InvalidNumberOfDigits); } if (options.Value.PeriodInSeconds < 30) { throw new ArgumentException(Resources.Exception_InvalidPeriodInSeconds); } _options = options.Value; _systemTime = systemTime; }