示例#1
0
        public static void AddRecaptcha(this IServiceCollection services, Action <RecaptchaOptions> configuration)
        {
            var configureOptions = new RecaptchaOptions();

            configuration(configureOptions);

            AddRecaptcha(services, configureOptions);
        }
示例#2
0
 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>();
 }
示例#3
0
        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
            };
        }