public static void AddRecaptcha(this IServiceCollection services, Action <RecaptchaOptions> configuration) { var configureOptions = new RecaptchaOptions(); configuration(configureOptions); AddRecaptcha(services, configureOptions); }
public static void AddRecaptcha(this IServiceCollection services, RecaptchaOptions configureOptions = null) { services.TryAddSingleton(Options.Create(configureOptions)); services.TryAddSingleton <IRecaptchaService, RecaptchaService>(); services.TryAddSingleton <IRecaptchaValidationService>((sp) => sp.GetRequiredService <IRecaptchaService>()); services.TryAddSingleton <IRecaptchaConfigurationService>((sp) => sp.GetRequiredService <IRecaptchaService>()); services.TryAddSingleton <IValidateRecaptchaFilter, ValidateRecaptchaFilter>(); services.TryAddSingleton <IHttpContextAccessor, HttpContextAccessor>(); }
public RecaptchaService(IOptions <RecaptchaOptions> options, IConfiguration configuration) { Options = options.Value ?? new RecaptchaOptions { SiteKey = configuration["Recaptcha:SiteKey"], SecretKey = configuration["Recaptcha:SecretKey"] }; ControlSettings = Options.ControlSettings ?? new RecaptchaControlSettings(); BackChannel = new HttpClient(Options.BackchannelHttpHandler ?? new HttpClientHandler()) { Timeout = Options.BackchannelTimeout }; }