pax_global_header00006660000000000000000000000064127275647400014530gustar00rootroot0000000000000052 comment=e4a08e17ca4e940e75daed2511c51b0321651c12 recaptcha-3.2.0/000077500000000000000000000000001272756474000134645ustar00rootroot00000000000000recaptcha-3.2.0/.gitignore000066400000000000000000000001021272756474000154450ustar00rootroot00000000000000rdoc pkg .ruby-gemset .ruby-version .bundle .gems .rbenv-gemsets recaptcha-3.2.0/.rubocop.yml000066400000000000000000000047321272756474000157440ustar00rootroot00000000000000# If you own a namespace and would like to enforce a different set of # rules, add a `.rubocop.yml` file to that directory. That configuration # can inherit from this file or override these rules entirely. LineLength: Max: 120 ClassLength: Enabled: false Style/StringLiterals: Enabled: false HashSyntax: EnforcedStyle: ruby19 Style/SpaceInsideHashLiteralBraces: Enabled: false Lint/AmbiguousOperator: Enabled: false Style/Lambda: Enabled: false Style/SpecialGlobalVars: Enabled: false Metrics/MethodLength: Enabled: false Metrics/AbcSize: Enabled: false Style/WordArray: Enabled: false Lint/EndAlignment: AlignWith: variable Style/StringLiteralsInInterpolation: Enabled: false Style/NumericLiterals: Enabled: false Style/FirstParameterIndentation: Enabled: false Style/IndentHash: Enabled: false Style/AlignParameters: EnforcedStyle: with_fixed_indentation Style/MultilineOperationIndentation: Enabled: false Metrics/ModuleLength: Enabled: false Metrics/PerceivedComplexity: Enabled: false Metrics/CyclomaticComplexity: Enabled: false Style/DoubleNegation: Enabled: false Style/Documentation: Enabled: false Metrics/CyclomaticComplexity: Enabled: false Style/MultilineMethodCallIndentation: EnforcedStyle: indented Style/ExtraSpacing: Enabled: false Style/DotPosition: EnforcedStyle: trailing Style/SingleLineBlockParams: Enabled: false Style/TrailingCommaInLiteral: Enabled: false Style/PerlBackrefs: Enabled: false Style/IfUnlessModifier: Enabled: false # alias / alias_method are both fine Style/Alias: Enabled: false # for simple cases more readable Style/GuardClause: Enabled: false # for single `/` more readable Style/RegexpLiteral: Enabled: false # %w[] shows that it will return an array Style/PercentLiteralDelimiters: PreferredDelimiters: '%i': '[]' '%w': '[]' '%W': '[]' Lint/AssignmentInCondition: Enabled: false Lint/AmbiguousRegexpLiteral: Enabled: false Metrics/ParameterLists: Enabled: false # looks correct / intuitive Lint/ParenthesesAsGroupedExpression: Enabled: false Style/FormatString: Enabled: false Metrics/BlockNesting: Enabled: false Style/IndentationWidth: Width: 2 Lint/NonLocalExitFromIterator: Enabled: false # often makes logical sense to not combine if with elsif Style/IfInsideElse: Enabled: false AllCops: TargetRubyVersion: 2.1 Include: - 'Rakefile' - 'Gemfile' - 'Rakefile' Exclude: - 'vendor/**/*' - 'demo/**/*' recaptcha-3.2.0/.travis.yml000066400000000000000000000001511272756474000155720ustar00rootroot00000000000000language: ruby cache: bundler sudo: false rvm: - 2.0.0 - 2.1.6 - 2.2.3 matrix: fast_finish: true recaptcha-3.2.0/CHANGELOG.md000066400000000000000000000041431272756474000152770ustar00rootroot00000000000000## 3.1.0 - 2016-06-10 * better error messages * frozen constants ## 3.0.0 - 2016-05-27 * remove all non-ssl options ## 2.3.0 - 2016-05-25 * enable ssl verification by default ... disable via `disable_ssl_verification = true` ## 2.2.0 - 2016-05-23 * Add global hostname validator config * Clean up after with_configuration exception ## 2.1.0 - 2016-05-19 * do not query google if repactcha was not submitted ## 2.0.0 - 2016-05-17 * remove stoken support, must use custom domain verification or domain whitelist ## 1.3.0 - 2016-04-07 * do not set model error and flash ## 1.2.0 - 2016-04-01 * custom domain validation ## 1.1.0 - 2016-01-27 * support RACK_ENV ## 1.0.2 - 2015-11-30 * nice deprecations for api_version ## 1.0.1 - 2015-11-30 * no longer defines `Rails` when `recaptcha/rails` is required ## 1.0.0 - 2015-11-30 * remove api v1 support * remove ssl_api_server_url, nonssl_api_server_url, change api_server_url to always need ssl option * removed activesupport dependency for .to_query * made flash and models both have descriptive errors ## 0.6.0 - 2015-11-19 * extract token module * need to use `gem "recaptcha", require: "recaptcha/rails"` to get rails helpers installed ## 0.5.0 - 2015-11-18 * size option * support disabling stoken * support Rails.env ## 0.3.6 / 2012-01-07 * Many documentation changes * Fixed deprecations in dependencies * Protocol relative JS includes * Fixes for options hash * Fixes for failing tests ## 0.3.5 / 2012-05-02 * I18n for error messages * Rails: delete flash keys if unused ## 0.3.4 / 2011-12-13 * Rails 3 * Remove jeweler ## 0.2.2 / 2009-09-14 * Add a timeout to the validator * Give the documentation some love ## 0.2.1 / 2009-09-14 * Removed Ambethia namespace, and restructured classes a bit * Added an example rails app in the example-rails branch ## 0.2.0 / 2009-09-12 * RecaptchaOptions AJAX API Fix * Added 'cucumber' as a test environment to skip * Ruby 1.9 compat fixes * Added option :message => 'Custom error message' to verify_recaptcha * Removed dependency on ActiveRecord constant * Add I18n ## 0.1.0 / 2008-2-8 * 1 major enhancement * Initial Gem Release recaptcha-3.2.0/Gemfile000066400000000000000000000000471272756474000147600ustar00rootroot00000000000000source 'https://rubygems.org' gemspec recaptcha-3.2.0/Gemfile.lock000066400000000000000000000027311272756474000157110ustar00rootroot00000000000000PATH remote: . specs: recaptcha (3.2.0) json GEM remote: https://rubygems.org/ specs: activesupport (4.2.5) i18n (~> 0.7) json (~> 1.7, >= 1.7.7) minitest (~> 5.1) thread_safe (~> 0.3, >= 0.3.4) tzinfo (~> 1.1) addressable (2.3.8) ast (2.3.0) bump (0.5.3) byebug (8.2.0) coderay (1.1.0) crack (0.4.2) safe_yaml (~> 1.0.0) hashdiff (0.2.3) i18n (0.7.0) json (1.8.3) maxitest (1.5.4) minitest (>= 5.0.0, < 5.9.0) metaclass (0.0.4) method_source (0.8.2) minitest (5.8.3) mocha (1.1.0) metaclass (~> 0.0.1) parser (2.3.1.2) ast (~> 2.2) powerpack (0.1.1) pry (0.10.3) coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) pry-byebug (3.3.0) byebug (~> 8.0) pry (~> 0.10) rainbow (2.1.0) rake (10.4.2) rubocop (0.40.0) parser (>= 2.3.1.0, < 3.0) powerpack (~> 0.1) rainbow (>= 1.99.1, < 3.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.8.1) safe_yaml (1.0.4) slop (3.6.0) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) unicode-display_width (1.0.5) webmock (1.22.3) addressable (>= 2.3.6) crack (>= 0.3.2) hashdiff PLATFORMS ruby DEPENDENCIES activesupport bump i18n maxitest mocha pry-byebug rake recaptcha! rubocop webmock BUNDLED WITH 1.12.3 recaptcha-3.2.0/LICENSE000066400000000000000000000020401272756474000144650ustar00rootroot00000000000000Copyright (c) 2007 Jason L Perry Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.recaptcha-3.2.0/README.md000066400000000000000000000136571272756474000147570ustar00rootroot00000000000000# reCAPTCHA Author: Jason L Perry (http://ambethia.com)
Copyright: Copyright (c) 2007-2013 Jason L Perry
License: [MIT](http://creativecommons.org/licenses/MIT/)
Info: https://github.com/ambethia/recaptcha
Bugs: https://github.com/ambethia/recaptcha/issues
This plugin adds helpers for the [reCAPTCHA API](https://www.google.com/recaptcha). In your views you can use the `recaptcha_tags` method to embed the needed javascript, and you can validate in your controllers with `verify_recaptcha` or `verify_recaptcha!`, which throws an error on failiure. ## Rails Installation [obtain a reCAPTCHA API key](https://www.google.com/recaptcha/admin). ```Ruby gem "recaptcha", require: "recaptcha/rails" ``` Keep keys out of the code base with environment variables.
Set in production and locally use [dotenv](https://github.com/bkeepers/dotenv), make sure to add it above recaptcha. Otherwise see [Alternative API key setup](#alternative-api-key-setup). ``` export RECAPTCHA_PUBLIC_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' export RECAPTCHA_PRIVATE_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx' ``` Add `recaptcha_tags` to the forms you want to protect. ```Erb <%= form_for @foo do |f| %> # ... other tags <%= recaptcha_tags %> # ... other tags <% end %> ``` And, add `verify_recaptcha` logic to each form action that you've protected. ```Ruby # app/controllers/users_controller.rb @user = User.new(params[:user].permit(:name)) if verify_recaptcha(model: @user) && @user.save redirect_to @user else render 'new' end ``` ## Sinatra / Rack / Ruby installation See [sinatra demo](/demo/sinatra) for details. - add `gem 'recaptcha'` to `Gemfile` - set env variables - `include Recaptcha::ClientHelper` where you need `recaptcha_tags` - `include Recaptcha::Verify` where you need `verify_recaptcha` ## recaptcha_tags Some of the options available: | Option | Description | |-------------|-------------| | :noscript | Include