pax_global_header 0000666 0000000 0000000 00000000064 13332414517 0014515 g ustar 00root root 0000000 0000000 52 comment=b01a7907c0a42049f25af63c45ec822f55ae8dab recaptcha-4.11.1/ 0000775 0000000 0000000 00000000000 13332414517 0013533 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/.gitignore 0000664 0000000 0000000 00000000102 13332414517 0015514 0 ustar 00root root 0000000 0000000 rdoc pkg .ruby-gemset .ruby-version .bundle .gems .rbenv-gemsets recaptcha-4.11.1/.rubocop.yml 0000664 0000000 0000000 00000004701 13332414517 0016007 0 ustar 00root root 0000000 0000000 AllCops: TargetRubyVersion: 2.3 Include: - 'Rakefile' - 'Gemfile' - 'Rakefile' Exclude: - 'vendor/**/*' - 'demo/**/*' LineLength: Max: 120 ClassLength: Enabled: false Style/StringLiterals: Enabled: false HashSyntax: EnforcedStyle: ruby19 Layout/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 Layout/EndAlignment: EnforcedStyleAlignWith: variable Style/StringLiteralsInInterpolation: Enabled: false Style/NumericLiterals: Enabled: false Layout/FirstParameterIndentation: Enabled: false Layout/IndentHash: Enabled: false Layout/AlignParameters: EnforcedStyle: with_fixed_indentation Layout/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 Layout/MultilineMethodCallIndentation: EnforcedStyle: indented Layout/ExtraSpacing: Enabled: false Layout/DotPosition: EnforcedStyle: trailing Style/SingleLineBlockParams: Enabled: false Style/TrailingCommaInArrayLiteral: Enabled: false Style/TrailingCommaInHashLiteral: 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 Layout/IndentationWidth: Width: 2 Lint/NonLocalExitFromIterator: Enabled: false # often makes logical sense to not combine if with elsif Style/IfInsideElse: Enabled: false Style/FrozenStringLiteralComment: Exclude: - 'test/**/*' Style/SymbolArray: Enabled: false recaptcha-4.11.1/.travis.yml 0000664 0000000 0000000 00000000400 13332414517 0015636 0 ustar 00root root 0000000 0000000 language: ruby cache: bundler sudo: false rvm: - 2.3 - 2.4 - 2.5 env: - TASK=test matrix: include: - rvm: 2.3 # keep same as lowest ruby version env: TASK=rubocop script: bundle exec rake $TASK branches: only: master matrix: fast_finish: true recaptcha-4.11.1/CHANGELOG.md 0000664 0000000 0000000 00000004607 13332414517 0015353 0 ustar 00root root 0000000 0000000 ## 4.11.0 - 2018-08-06 * prefer RAILS_ENV over RACK_ENV #286 ## 4.0.0 - 2016-11-14 * public_key -> site_key and private_key -> secret_key ## 3.4.0 - 2016-11-01 * Update fallback html ## 3.2.0 - 2016-06-13 * remove SKIP_VERIFY_ENV constant, use `skip_verify_env` instance variable instead ## 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-4.11.1/Gemfile 0000664 0000000 0000000 00000000106 13332414517 0015023 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true source 'https://rubygems.org' gemspec recaptcha-4.11.1/Gemfile.lock 0000664 0000000 0000000 00000003172 13332414517 0015760 0 ustar 00root root 0000000 0000000 PATH remote: . specs: recaptcha (4.11.1) json GEM remote: https://rubygems.org/ specs: activesupport (5.2.0) concurrent-ruby (~> 1.0, >= 1.0.2) i18n (>= 0.7, < 2) minitest (~> 5.1) tzinfo (~> 1.1) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) ast (2.4.0) bump (0.6.1) byebug (10.0.2) coderay (1.1.2) concurrent-ruby (1.0.5) crack (0.4.3) safe_yaml (~> 1.0.0) hashdiff (0.3.7) i18n (1.0.1) concurrent-ruby (~> 1.0) jaro_winkler (1.5.1) json (2.1.0) maxitest (3.1.0) minitest (>= 5.0.0, < 5.12.0) metaclass (0.0.4) method_source (0.9.0) minitest (5.11.3) mocha (1.5.0) metaclass (~> 0.0.1) parallel (1.12.1) parser (2.5.1.0) ast (~> 2.4.0) powerpack (0.1.2) pry (0.11.3) coderay (~> 1.1.0) method_source (~> 0.9.0) pry-byebug (3.6.0) byebug (~> 10.0) pry (~> 0.10) public_suffix (3.0.2) rainbow (3.0.0) rake (12.3.1) rubocop (0.57.2) jaro_winkler (~> 1.5.1) parallel (~> 1.10) parser (>= 2.5) powerpack (~> 0.1) rainbow (>= 2.2.2, < 4.0) ruby-progressbar (~> 1.7) unicode-display_width (~> 1.0, >= 1.0.1) ruby-progressbar (1.9.0) safe_yaml (1.0.4) thread_safe (0.3.6) tzinfo (1.2.5) thread_safe (~> 0.1) unicode-display_width (1.4.0) webmock (3.4.2) 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.16.1 recaptcha-4.11.1/LICENSE 0000664 0000000 0000000 00000002040 13332414517 0014534 0 ustar 00root root 0000000 0000000 Copyright (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-4.11.1/README.md 0000664 0000000 0000000 00000021751 13332414517 0015020 0 ustar 00root root 0000000 0000000 # 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). Note: Use localhost or 127.0.0.1 in domain if using localhost:3000. ```Ruby gem "recaptcha" ``` 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_SITE_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' export RECAPTCHA_SECRET_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 content (default `true`)| | :theme | Specify the theme to be used per the API. Available options: `dark` and `light`. (default `light`)| | :ajax | Render the dynamic AJAX captcha per the API. (default `false`)| | :site_key | Override site API key | | :error | Override the error code returned from the reCAPTCHA API (default `nil`)| | :size | Specify a size (default `nil`)| | :hl | Optional. Forces the widget to render in a specific language. Auto-detects the user's language if unspecified. (See [language codes](https://developers.google.com/recaptcha/docs/language)) | | :nonce | Optional. Sets nonce attribute for script. Can be generated via `SecureRandom.base64(32)`. (default `nil`)| | :id | Specify an html id attribute (default `nil`)| | :script | If you do not need to add a script tag by helper you can set the option to false. It's necessary when you add a script tag manualy (default `true`)| | :callback | Optional. Name of success callback function, executed when the user submits a successful response | | :expired_callback | Optional. Name of expiration callback function, executed when the reCAPTCHA response expires and the user needs to re-verify. | | :error_callback | Optional. Name of error callback function, executed when reCAPTCHA encounters an error (e.g. network connectivity) | You can also override the html attributes for the sizes of the generated `textarea` and `iframe` elements, if CSS isn't your thing. Inspect the source of `recaptcha_tags` to see these options. ## verify_recaptcha This method returns `true` or `false` after processing the parameters from the reCAPTCHA widget. Why isn't this a model validation? Because that violates MVC. You can use it like this, or how ever you like. Passing in the ActiveRecord object is optional, if you do--and the captcha fails to verify--an error will be added to the object for you to use. Some of the options available: | Option | Description | |--------------|-------------| | :model | Model to set errors. | :attribute | Model attribute to receive errors. (default :base) | :message | Custom error message. | :secret_key | Override secret API key. | :timeout | The number of seconds to wait for reCAPTCHA servers before give up. (default `3`) | :response | Custom response parameter. (default: params['g-recaptcha-response']) | :hostname | Expected hostname or a callable that validates the hostname, see [domain validation](https://developers.google.com/recaptcha/docs/domain_validation) and [hostname](https://developers.google.com/recaptcha/docs/verify#api-response) docs. (default: `nil`, but can be changed by setting `config.hostname`) | :env | Current environment. The request to verify will be skipped if the environment is specified in configuration under `skip_verify_env` ## invisible_recaptcha_tags Make sure to read [Invisible reCAPTCHA](https://developers.google.com/recaptcha/docs/invisible). ### With a single form on a page 1. The `invisible_recaptcha_tags` generates a submit button for you. ```Erb <%= form_for @foo do |f| %> # ... other tags <%= invisible_recaptcha_tags text: 'Submit form' %> <% end %> ``` Then, add `verify_recaptcha` to your controller as seen [above](#rails-installation). ### With multiple forms on a page 1. You will need a custom callback function, which is called after verification with Google's reCAPTCHA service. This callback function must submit the form. Optionally, `invisible_recaptcha_tags` currently implements a JS function called `invisibleRecaptchaSubmit` that is called when no `callback` is passed. Should you wish to override `invisibleRecaptchaSubmit`, you will need to use `invisible_recaptcha_tags script: false`, see lib/recaptcha/client_helper.rb for details. 2. The `invisible_recaptcha_tags` generates a submit button for you. ```Erb <%= form_for @foo, html: {id: 'invisible-recaptcha-form'} do |f| %> # ... other tags <%= invisible_recaptcha_tags callback: 'submitInvisibleRecaptchaForm', text: 'Submit form' %> <% end %> ``` ```Javascript // app/assets/javascripts/application.js var submitInvisibleRecaptchaForm = function () { document.getElementById("invisible-recaptcha-form").submit(); }; ``` Finally, add `verify_recaptcha` to your controller as seen [above](#rails-installation). ### Programmatically invoke 1. Specify `ui` option ```Erb <%= form_for @foo, html: {id: 'invisible-recaptcha-form'} do |f| %> # ... other tags Submit <%= invisible_recaptcha_tags ui: :invisible, callback: 'submitInvisibleRecaptchaForm' %> <% end %> ``` ```Javascript // app/assets/javascripts/application.js document.getElementById('submit-btn').addEventListener('click', function (e) { // do some validation if(isValid) { // call reCAPTCHA check grecaptcha.execute(); } }); var submitInvisibleRecaptchaForm = function () { document.getElementById("invisible-recaptcha-form").submit(); }; ``` ## I18n support reCAPTCHA passes two types of error explanation to a linked model. It will use the I18n gem to translate the default error message if I18n is available. To customize the messages to your locale, add these keys to your I18n backend: `recaptcha.errors.verification_failed` error message displayed if the captcha words didn't match `recaptcha.errors.recaptcha_unreachable` displayed if a timeout error occured while attempting to verify the captcha Also you can translate API response errors to human friendly by adding translations to the locale (`config/locales/en.yml`): ```Yaml en: recaptcha: errors: verification_failed: 'Fail' ``` ## Testing By default, reCAPTCHA is skipped in "test" and "cucumber" env. To enable it during test: ```Ruby Recaptcha.configuration.skip_verify_env.delete("test") ``` ## Alternative API key setup ### Recaptcha.configure ```Ruby # config/initializers/recaptcha.rb Recaptcha.configure do |config| config.site_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' config.secret_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx' # Uncomment the following line if you are using a proxy server: # config.proxy = 'http://myproxy.com.au:8080' end ``` ### Recaptcha.with_configuration For temporary overwrites (not thread safe). ```Ruby Recaptcha.with_configuration(site_key: '12345') do # Do stuff with the overwritten site_key. end ``` ### Per call Pass in keys as options at runtime, for code base with multiple reCAPTCHA setups: ```Ruby recaptcha_tags site_key: '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy' # and verify_recaptcha secret_key: '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx' ``` ## Misc - Check out the [wiki](https://github.com/ambethia/recaptcha/wiki) and leave whatever you found valuable there. - [Add multiple widgets to the same page](https://github.com/ambethia/recaptcha/wiki/Add-multiple-widgets-to-the-same-page) - [Use Recaptcha with Devise](https://github.com/plataformatec/devise/wiki/How-To:-Use-Recaptcha-with-Devise) recaptcha-4.11.1/Rakefile 0000664 0000000 0000000 00000000501 13332414517 0015174 0 ustar 00root root 0000000 0000000 # frozen_string_literal: true require "bundler/setup" require "bundler/gem_tasks" require "rake/testtask" require "bump/tasks" task default: [:test, :rubocop] Rake::TestTask.new do |t| t.test_files = FileList['test/*_test.rb'] end desc "rubocop" task :rubocop do sh "rubocop" end task default: [:test, :rubocop] recaptcha-4.11.1/demo/ 0000775 0000000 0000000 00000000000 13332414517 0014457 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/ 0000775 0000000 0000000 00000000000 13332414517 0015571 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/.env 0000664 0000000 0000000 00000000324 13332414517 0016361 0 ustar 00root root 0000000 0000000 # reCAPTCHA keys for testing purposes # Make your own at https://www.google.com/recaptcha RECAPTCHA_SITE_KEY=6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI RECAPTCHA_SECRET_KEY=6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe recaptcha-4.11.1/demo/rails/.gitignore 0000664 0000000 0000000 00000000732 13332414517 0017563 0 ustar 00root root 0000000 0000000 # See https://help.github.com/articles/ignoring-files for more about ignoring files. # # If you find yourself ignoring temporary files generated by your text editor # or operating system, you probably want to add a global ignore instead: # git config --global core.excludesfile '~/.gitignore_global' # Ignore bundler config. /.bundle # Ignore the default SQLite database. /db/*.sqlite3 /db/*.sqlite3-journal # Ignore all logfiles and tempfiles. /log/* !/log/.keep /tmp recaptcha-4.11.1/demo/rails/Gemfile 0000664 0000000 0000000 00000000257 13332414517 0017070 0 ustar 00root root 0000000 0000000 source 'https://rubygems.org' gem 'dotenv-rails', groups: [:development, :test] gem 'rails', '4.2.5' gem 'sqlite3' gem 'recaptcha', require: 'recaptcha/rails', path: '../..' recaptcha-4.11.1/demo/rails/Gemfile.lock 0000664 0000000 0000000 00000005227 13332414517 0020021 0 ustar 00root root 0000000 0000000 PATH remote: ../.. specs: recaptcha (3.3.0) json GEM remote: https://rubygems.org/ specs: actionmailer (4.2.5) actionpack (= 4.2.5) actionview (= 4.2.5) activejob (= 4.2.5) mail (~> 2.5, >= 2.5.4) rails-dom-testing (~> 1.0, >= 1.0.5) actionpack (4.2.5) actionview (= 4.2.5) activesupport (= 4.2.5) rack (~> 1.6) rack-test (~> 0.6.2) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) actionview (4.2.5) activesupport (= 4.2.5) builder (~> 3.1) erubis (~> 2.7.0) rails-dom-testing (~> 1.0, >= 1.0.5) rails-html-sanitizer (~> 1.0, >= 1.0.2) activejob (4.2.5) activesupport (= 4.2.5) globalid (>= 0.3.0) activemodel (4.2.5) activesupport (= 4.2.5) builder (~> 3.1) activerecord (4.2.5) activemodel (= 4.2.5) activesupport (= 4.2.5) arel (~> 6.0) 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) arel (6.0.3) builder (3.2.2) dotenv (2.0.2) dotenv-rails (2.0.2) dotenv (= 2.0.2) railties (~> 4.0) erubis (2.7.0) globalid (0.3.6) activesupport (>= 4.1.0) i18n (0.7.0) json (1.8.3) loofah (2.0.3) nokogiri (>= 1.5.9) mail (2.6.3) mime-types (>= 1.16, < 3) mime-types (2.99) mini_portile (0.6.2) minitest (5.8.3) nokogiri (1.6.6.4) mini_portile (~> 0.6.0) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) rails (4.2.5) actionmailer (= 4.2.5) actionpack (= 4.2.5) actionview (= 4.2.5) activejob (= 4.2.5) activemodel (= 4.2.5) activerecord (= 4.2.5) activesupport (= 4.2.5) bundler (>= 1.3.0, < 2.0) railties (= 4.2.5) sprockets-rails rails-deprecated_sanitizer (1.0.3) activesupport (>= 4.2.0.alpha) rails-dom-testing (1.0.7) activesupport (>= 4.2.0.beta, < 5.0) nokogiri (~> 1.6.0) rails-deprecated_sanitizer (>= 1.0.1) rails-html-sanitizer (1.0.2) loofah (~> 2.0) railties (4.2.5) actionpack (= 4.2.5) activesupport (= 4.2.5) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.4.2) sprockets (3.4.0) rack (> 1, < 3) sprockets-rails (2.3.3) actionpack (>= 3.0) activesupport (>= 3.0) sprockets (>= 2.8, < 4.0) sqlite3 (1.3.11) thor (0.19.1) thread_safe (0.3.5) tzinfo (1.2.2) thread_safe (~> 0.1) PLATFORMS ruby DEPENDENCIES dotenv-rails rails (= 4.2.5) recaptcha! sqlite3 BUNDLED WITH 1.12.5 recaptcha-4.11.1/demo/rails/Rakefile 0000664 0000000 0000000 00000000371 13332414517 0017237 0 ustar 00root root 0000000 0000000 # Add your own tasks in files placed in lib/tasks ending in .rake, # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. require File.expand_path('../config/application', __FILE__) Rails.application.load_tasks recaptcha-4.11.1/demo/rails/app/ 0000775 0000000 0000000 00000000000 13332414517 0016351 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/assets/ 0000775 0000000 0000000 00000000000 13332414517 0017653 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/assets/javascripts/ 0000775 0000000 0000000 00000000000 13332414517 0022204 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/assets/javascripts/application.js 0000664 0000000 0000000 00000001124 13332414517 0025043 0 ustar 00root root 0000000 0000000 // This is a manifest file that'll be compiled into application.js, which will include all the files // listed below. // // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. // // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the // compiled file. // // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details // about supported directives. // //= require_tree . recaptcha-4.11.1/demo/rails/app/assets/stylesheets/ 0000775 0000000 0000000 00000000000 13332414517 0022227 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/assets/stylesheets/application.css 0000664 0000000 0000000 00000001256 13332414517 0025250 0 ustar 00root root 0000000 0000000 /* * This is a manifest file that'll be compiled into application.css, which will include all the files * listed below. * * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. * * You're free to add application-wide styles to this file and they'll appear at the bottom of the * compiled file so the styles you add here take precedence over styles defined in any styles * defined in the other CSS/SCSS files in this directory. It is generally better to create a new * file per style scope. * *= require_tree . *= require_self */ recaptcha-4.11.1/demo/rails/app/controllers/ 0000775 0000000 0000000 00000000000 13332414517 0020717 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/controllers/application_controller.rb 0000664 0000000 0000000 00000000314 13332414517 0026010 0 ustar 00root root 0000000 0000000 class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception end recaptcha-4.11.1/demo/rails/app/controllers/captcha_controller.rb 0000664 0000000 0000000 00000000264 13332414517 0025114 0 ustar 00root root 0000000 0000000 class CaptchaController < ApplicationController def index end def create if verify_recaptcha render text: 'YES' else render text: 'NO' end end end recaptcha-4.11.1/demo/rails/app/controllers/concerns/ 0000775 0000000 0000000 00000000000 13332414517 0022531 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/controllers/concerns/.keep 0000664 0000000 0000000 00000000000 13332414517 0023444 0 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/controllers/users_controller.rb 0000664 0000000 0000000 00000000563 13332414517 0024654 0 ustar 00root root 0000000 0000000 class UsersController < ApplicationController def index @users = User.all end def edit @user = User.find(params[:id]) end def update @user = User.find(params[:id]) if verify_recaptcha(model: @user, message: 'Error in passing CAPTCHA.') && @user.save redirect_to users_path, notice: "Saved" else render 'edit' end end end recaptcha-4.11.1/demo/rails/app/helpers/ 0000775 0000000 0000000 00000000000 13332414517 0020013 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/helpers/application_helper.rb 0000664 0000000 0000000 00000000035 13332414517 0024200 0 ustar 00root root 0000000 0000000 module ApplicationHelper end recaptcha-4.11.1/demo/rails/app/mailers/ 0000775 0000000 0000000 00000000000 13332414517 0020005 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/mailers/.keep 0000664 0000000 0000000 00000000000 13332414517 0020720 0 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/models/ 0000775 0000000 0000000 00000000000 13332414517 0017634 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/models/.keep 0000664 0000000 0000000 00000000000 13332414517 0020547 0 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/models/user.rb 0000664 0000000 0000000 00000000044 13332414517 0021135 0 ustar 00root root 0000000 0000000 class User < ActiveRecord::Base end recaptcha-4.11.1/demo/rails/app/views/ 0000775 0000000 0000000 00000000000 13332414517 0017506 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/views/captcha/ 0000775 0000000 0000000 00000000000 13332414517 0021111 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/views/captcha/index.html.erb 0000664 0000000 0000000 00000003306 13332414517 0023657 0 ustar 00root root 0000000 0000000 <% if params[:multi] %> <%= form_tag "/captchas" do |f| %> <%= submit_tag %> <% end %> <%= form_tag "/captchas" do %> <%= submit_tag %> <% end %> <%= form_tag "/captchas" do %> <%= submit_tag %> <% end %> <% elsif params[:invisible] %> <%= form_tag "/captchas", id: "invisible-recaptcha-form" do %> <%= invisible_recaptcha_tags text: 'Save changes' %> <% end %> <% else %> <%= form_tag "/captchas" do %> <%= recaptcha_tags %> <%= submit_tag %> <% end %> <% end %> <%= link_to 'Single ?', '?' if params[:multi] or params[:invisible] %> <%= link_to 'Multi ?', '?multi=1' unless params[:multi] %> <%= link_to 'Invisible ?', '?invisible=1' unless params[:invisible] %> recaptcha-4.11.1/demo/rails/app/views/layouts/ 0000775 0000000 0000000 00000000000 13332414517 0021206 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/views/layouts/application.html.erb 0000664 0000000 0000000 00000000552 13332414517 0025150 0 ustar 00root root 0000000 0000000 Foo <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %> <%= javascript_include_tag 'application', 'data-turbolinks-track' => true %> <%= csrf_meta_tags %> <% flash.each do |k,v| %> <%= k %>: <%= v %> <% end %> <%= yield %> recaptcha-4.11.1/demo/rails/app/views/users/ 0000775 0000000 0000000 00000000000 13332414517 0020647 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/app/views/users/edit.html.erb 0000664 0000000 0000000 00000000155 13332414517 0023232 0 ustar 00root root 0000000 0000000 <%= form_for @user do |f| %> <%= f.text_field :name %> <%= recaptcha_tags %> <%= f.submit %> <% end %> recaptcha-4.11.1/demo/rails/app/views/users/index.html.erb 0000664 0000000 0000000 00000000200 13332414517 0023403 0 ustar 00root root 0000000 0000000 <% @users.each do |user| %> <%= link_to user.name, edit_user_path(user) %> <% end %> recaptcha-4.11.1/demo/rails/bin/ 0000775 0000000 0000000 00000000000 13332414517 0016341 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/bin/bundle 0000775 0000000 0000000 00000000201 13332414517 0017531 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) load Gem.bin_path('bundler', 'bundle') recaptcha-4.11.1/demo/rails/bin/rails 0000775 0000000 0000000 00000000414 13332414517 0017400 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby begin load File.expand_path('../spring', __FILE__) rescue LoadError => e raise unless e.message.include?('spring') end APP_PATH = File.expand_path('../../config/application', __FILE__) require_relative '../config/boot' require 'rails/commands' recaptcha-4.11.1/demo/rails/bin/rake 0000775 0000000 0000000 00000000325 13332414517 0017211 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby begin load File.expand_path('../spring', __FILE__) rescue LoadError => e raise unless e.message.include?('spring') end require_relative '../config/boot' require 'rake' Rake.application.run recaptcha-4.11.1/demo/rails/bin/setup 0000775 0000000 0000000 00000001445 13332414517 0017433 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby require 'pathname' # path to your application root. APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) Dir.chdir APP_ROOT do # This script is a starting point to setup your application. # Add necessary setup steps to this file: puts "== Installing dependencies ==" system "gem install bundler --conservative" system "bundle check || bundle install" # puts "\n== Copying sample files ==" # unless File.exist?("config/database.yml") # system "cp config/database.yml.sample config/database.yml" # end puts "\n== Preparing database ==" system "bin/rake db:setup" puts "\n== Removing old logs and tempfiles ==" system "rm -f log/*" system "rm -rf tmp/cache" puts "\n== Restarting application server ==" system "touch tmp/restart.txt" end recaptcha-4.11.1/demo/rails/bin/spring 0000775 0000000 0000000 00000000717 13332414517 0017576 0 ustar 00root root 0000000 0000000 #!/usr/bin/env ruby # This file loads spring without using Bundler, in order to be fast. # It gets overwritten when you run the `spring binstub` command. unless defined?(Spring) require 'rubygems' require 'bundler' if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)) Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq } gem 'spring', match[1] require 'spring/binstub' end end recaptcha-4.11.1/demo/rails/config.ru 0000664 0000000 0000000 00000000231 13332414517 0017402 0 ustar 00root root 0000000 0000000 # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) run Rails.application recaptcha-4.11.1/demo/rails/config/ 0000775 0000000 0000000 00000000000 13332414517 0017036 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/config/application.rb 0000664 0000000 0000000 00000002126 13332414517 0021667 0 ustar 00root root 0000000 0000000 require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Foo class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true end end recaptcha-4.11.1/demo/rails/config/boot.rb 0000664 0000000 0000000 00000000204 13332414517 0020322 0 ustar 00root root 0000000 0000000 ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' # Set up gems listed in the Gemfile. recaptcha-4.11.1/demo/rails/config/database.yml 0000664 0000000 0000000 00000001050 13332414517 0021321 0 ustar 00root root 0000000 0000000 # SQLite version 3.x # gem install sqlite3 # # Ensure the SQLite 3 gem is defined in your Gemfile # gem 'sqlite3' # default: &default adapter: sqlite3 pool: 5 timeout: 5000 development: <<: *default database: db/development.sqlite3 # Warning: The database defined as "test" will be erased and # re-generated from your development database when you run "rake". # Do not set this db to the same as development or production. test: <<: *default database: db/test.sqlite3 production: <<: *default database: db/production.sqlite3 recaptcha-4.11.1/demo/rails/config/environment.rb 0000664 0000000 0000000 00000000226 13332414517 0021727 0 ustar 00root root 0000000 0000000 # Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize! recaptcha-4.11.1/demo/rails/config/environments/ 0000775 0000000 0000000 00000000000 13332414517 0021565 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/config/environments/development.rb 0000664 0000000 0000000 00000003100 13332414517 0024426 0 ustar 00root root 0000000 0000000 Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Asset digests allow you to set far-future HTTP expiration dates on all assets, # yet still be able to expire them through the digest params. config.assets.digest = true # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. config.assets.raise_runtime_errors = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end recaptcha-4.11.1/demo/rails/config/initializers/ 0000775 0000000 0000000 00000000000 13332414517 0021544 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/config/initializers/assets.rb 0000664 0000000 0000000 00000000746 13332414517 0023402 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js ) recaptcha-4.11.1/demo/rails/config/initializers/backtrace_silencers.rb 0000664 0000000 0000000 00000000624 13332414517 0026061 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers! recaptcha-4.11.1/demo/rails/config/initializers/cookies_serializer.rb 0000664 0000000 0000000 00000000201 13332414517 0025747 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.cookies_serializer = :json recaptcha-4.11.1/demo/rails/config/initializers/filter_parameter_logging.rb 0000664 0000000 0000000 00000000302 13332414517 0027117 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password] recaptcha-4.11.1/demo/rails/config/initializers/inflections.rb 0000664 0000000 0000000 00000001207 13332414517 0024406 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end recaptcha-4.11.1/demo/rails/config/initializers/mime_types.rb 0000664 0000000 0000000 00000000234 13332414517 0024243 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf recaptcha-4.11.1/demo/rails/config/initializers/session_store.rb 0000664 0000000 0000000 00000000207 13332414517 0024767 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_foo_session' recaptcha-4.11.1/demo/rails/config/initializers/wrap_parameters.rb 0000664 0000000 0000000 00000001005 13332414517 0025261 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true # end recaptcha-4.11.1/demo/rails/config/locales/ 0000775 0000000 0000000 00000000000 13332414517 0020460 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/config/locales/en.yml 0000664 0000000 0000000 00000001172 13332414517 0021606 0 ustar 00root root 0000000 0000000 # Files in the config/locales directory are used for internationalization # and are automatically loaded by Rails. If you want to use locales other # than English, add the necessary files in this directory. # # To use the locales, use `I18n.t`: # # I18n.t 'hello' # # In views, this is aliased to just `t`: # # <%= t('hello') %> # # To use a different locale, set it with `I18n.locale`: # # I18n.locale = :es # # This would use the information in config/locales/es.yml. # # To learn more, please read the Rails Internationalization guide # available at http://guides.rubyonrails.org/i18n.html. en: hello: "Hello world" recaptcha-4.11.1/demo/rails/config/routes.rb 0000664 0000000 0000000 00000000172 13332414517 0020704 0 ustar 00root root 0000000 0000000 Rails.application.routes.draw do root to: "captcha#index" post "/captchas" => "captcha#create" resources :users end recaptcha-4.11.1/demo/rails/config/secrets.yml 0000664 0000000 0000000 00000001704 13332414517 0021233 0 ustar 00root root 0000000 0000000 # Be sure to restart your server when you modify this file. # Your secret key is used for verifying the integrity of signed cookies. # If you change this key, all old signed cookies will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. # You can use `rake secret` to generate a secure secret key. # Make sure the secrets in this file are kept private # if you're sharing your code publicly. development: secret_key_base: c9f78eaa370cf6e763541491003469a07754b0ed2d37638e13c892540ecae39311ed928af595b3b7603807950c46ca49249e5c8c9db7c1faccbe71a6bb76cee9 test: secret_key_base: a9bd3f4f67f18b8a9333886d8552528265d5962385de1b1f2b3883214c06d6a53dced9fc954b9649de9c8e4da0925d41427aad6d4aa76e5570eade23ab27c85c # Do not keep production secrets in the repository, # instead read values from the environment. production: secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> recaptcha-4.11.1/demo/rails/db/ 0000775 0000000 0000000 00000000000 13332414517 0016156 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/db/migrate/ 0000775 0000000 0000000 00000000000 13332414517 0017606 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/db/migrate/20151226015155_add_user.rb 0000664 0000000 0000000 00000000173 13332414517 0023365 0 ustar 00root root 0000000 0000000 class AddUser < ActiveRecord::Migration def change create_table :users do |t| t.string :name end end end recaptcha-4.11.1/demo/rails/db/schema.rb 0000664 0000000 0000000 00000001554 13332414517 0017750 0 ustar 00root root 0000000 0000000 # encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20151226015155) do create_table "users", force: :cascade do |t| t.string "name" end end recaptcha-4.11.1/demo/rails/db/seeds.rb 0000664 0000000 0000000 00000000034 13332414517 0017603 0 ustar 00root root 0000000 0000000 User.create! name: "Tester" recaptcha-4.11.1/demo/rails/public/ 0000775 0000000 0000000 00000000000 13332414517 0017047 5 ustar 00root root 0000000 0000000 recaptcha-4.11.1/demo/rails/public/favicon.ico 0000664 0000000 0000000 00000070456 13332414517 0021204 0 ustar 00root root 0000000 0000000 00 % 6 00 % % 00 % K ( 0 ` ` ` k 8 V , q q n I g 6 y = 6 6 ^ 6 0 6 - m u Z b t 2 6 K y 6 u ^ ^ m / L ! ' X 6 a Z 6 0 X 2 x F z <