recaptcha 0.3.6 → 5.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,4 @@
1
- require 'net/http'
2
- require 'recaptcha'
1
+ # frozen_string_literal: true
3
2
 
4
- ActionView::Base.send(:include, Recaptcha::ClientHelper)
5
- ActionController::Base.send(:include, Recaptcha::Verify)
3
+ # deprecated, but let's not blow everyone up
4
+ require 'recaptcha'
@@ -1,15 +1,35 @@
1
- require 'net/http'
2
- require 'recaptcha'
3
- module Rails
4
- module Recaptcha
5
- class Railtie < Rails::Railtie
6
- initializer "setup config" do
7
- begin
8
- ActionView::Base.send(:include, ::Recaptcha::ClientHelper)
9
- ActionController::Base.send(:include, ::Recaptcha::Verify)
10
- end
1
+ # frozen_string_literal: true
2
+
3
+ module Recaptcha
4
+ class Railtie < Rails::Railtie
5
+ ActiveSupport.on_load(:action_view) do
6
+ include Recaptcha::Adapters::ViewMethods
7
+ end
8
+
9
+ ActiveSupport.on_load(:action_controller) do
10
+ include Recaptcha::Adapters::ControllerMethods
11
+ end
12
+
13
+ initializer 'recaptcha' do |app|
14
+ Recaptcha::Railtie.instance_eval do
15
+ pattern = pattern_from app.config.i18n.available_locales
16
+
17
+ add("rails/locales/#{pattern}.yml")
18
+ end
19
+ end
20
+
21
+ class << self
22
+ protected
23
+
24
+ def add(pattern)
25
+ files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)]
26
+ I18n.load_path.concat(files)
27
+ end
28
+
29
+ def pattern_from(args)
30
+ array = Array(args || [])
31
+ array.blank? ? '*' : "{#{array.join ','}}"
11
32
  end
12
33
  end
13
34
  end
14
35
  end
15
-
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Recaptcha
2
- VERSION = "0.3.6"
4
+ VERSION = '5.6.0'
3
5
  end
@@ -0,0 +1,5 @@
1
+ en:
2
+ recaptcha:
3
+ errors:
4
+ verification_failed: reCAPTCHA verification failed, please try again.
5
+ recaptcha_unreachable: Oops, we failed to validate your reCAPTCHA response. Please try again.
metadata CHANGED
@@ -1,119 +1,182 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: recaptcha
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 5.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason L Perry
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-07 00:00:00.000000000 Z
11
+ date: 2020-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: json
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: mocha
15
29
  requirement: !ruby/object:Gem::Requirement
16
30
  requirements:
17
- - - '>='
31
+ - - ">="
18
32
  - !ruby/object:Gem::Version
19
33
  version: '0'
20
34
  type: :development
21
35
  prerelease: false
22
36
  version_requirements: !ruby/object:Gem::Requirement
23
37
  requirements:
24
- - - '>='
38
+ - - ">="
25
39
  - !ruby/object:Gem::Version
26
40
  version: '0'
27
41
  - !ruby/object:Gem::Dependency
28
42
  name: rake
29
43
  requirement: !ruby/object:Gem::Requirement
30
44
  requirements:
31
- - - '>='
45
+ - - ">="
32
46
  - !ruby/object:Gem::Version
33
47
  version: '0'
34
48
  type: :development
35
49
  prerelease: false
36
50
  version_requirements: !ruby/object:Gem::Requirement
37
51
  requirements:
38
- - - '>='
52
+ - - ">="
39
53
  - !ruby/object:Gem::Version
40
54
  version: '0'
41
55
  - !ruby/object:Gem::Dependency
42
- name: activesupport
56
+ name: i18n
43
57
  requirement: !ruby/object:Gem::Requirement
44
58
  requirements:
45
- - - '>='
59
+ - - ">="
46
60
  - !ruby/object:Gem::Version
47
61
  version: '0'
48
62
  type: :development
49
63
  prerelease: false
50
64
  version_requirements: !ruby/object:Gem::Requirement
51
65
  requirements:
52
- - - '>='
66
+ - - ">="
53
67
  - !ruby/object:Gem::Version
54
68
  version: '0'
55
69
  - !ruby/object:Gem::Dependency
56
- name: i18n
70
+ name: maxitest
57
71
  requirement: !ruby/object:Gem::Requirement
58
72
  requirements:
59
- - - '>='
73
+ - - ">="
60
74
  - !ruby/object:Gem::Version
61
75
  version: '0'
62
76
  type: :development
63
77
  prerelease: false
64
78
  version_requirements: !ruby/object:Gem::Requirement
65
79
  requirements:
66
- - - '>='
80
+ - - ">="
67
81
  - !ruby/object:Gem::Version
68
82
  version: '0'
69
- description: This plugin adds helpers for the reCAPTCHA API
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry-byebug
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: bump
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: webmock
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description: Helpers for the reCAPTCHA API
70
140
  email:
71
141
  - jasper@ambethia.com
72
142
  executables: []
73
143
  extensions: []
74
144
  extra_rdoc_files: []
75
145
  files:
76
- - .gitignore
77
- - CHANGELOG
78
- - Gemfile
146
+ - CHANGELOG.md
79
147
  - LICENSE
80
- - README.rdoc
81
- - Rakefile
82
- - init.rb
148
+ - README.md
83
149
  - lib/recaptcha.rb
84
- - lib/recaptcha/client_helper.rb
150
+ - lib/recaptcha/adapters/controller_methods.rb
151
+ - lib/recaptcha/adapters/view_methods.rb
85
152
  - lib/recaptcha/configuration.rb
86
- - lib/recaptcha/merb.rb
153
+ - lib/recaptcha/helpers.rb
87
154
  - lib/recaptcha/rails.rb
88
155
  - lib/recaptcha/railtie.rb
89
- - lib/recaptcha/verify.rb
90
156
  - lib/recaptcha/version.rb
91
- - recaptcha.gemspec
92
- - test/recaptcha_test.rb
93
- - test/verify_recaptcha_test.rb
157
+ - rails/locales/en.yml
94
158
  homepage: http://github.com/ambethia/recaptcha
95
- licenses: []
96
- metadata: {}
159
+ licenses:
160
+ - MIT
161
+ metadata:
162
+ source_code_uri: https://github.com/ambethia/recaptcha
97
163
  post_install_message:
98
164
  rdoc_options: []
99
165
  require_paths:
100
166
  - lib
101
167
  required_ruby_version: !ruby/object:Gem::Requirement
102
168
  requirements:
103
- - - '>='
169
+ - - ">="
104
170
  - !ruby/object:Gem::Version
105
- version: '0'
171
+ version: 2.3.0
106
172
  required_rubygems_version: !ruby/object:Gem::Requirement
107
173
  requirements:
108
- - - '>='
174
+ - - ">="
109
175
  - !ruby/object:Gem::Version
110
176
  version: '0'
111
177
  requirements: []
112
- rubyforge_project: recaptcha
113
- rubygems_version: 2.1.10
178
+ rubygems_version: 3.1.3
114
179
  signing_key:
115
180
  specification_version: 4
116
181
  summary: Helpers for the reCAPTCHA API
117
- test_files:
118
- - test/recaptcha_test.rb
119
- - test/verify_recaptcha_test.rb
182
+ test_files: []
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- rdoc
2
- pkg
3
- Gemfile.lock
data/CHANGELOG DELETED
@@ -1,33 +0,0 @@
1
- == 0.3.5 / 2012-05-02
2
-
3
- * I18n for error messages
4
- * Rails: delete flash keys if unused
5
-
6
- == 0.3.4 / 2011-12-13
7
-
8
- * Rails 3
9
- * Remove jeweler
10
-
11
- == 0.2.2 / 2009-09-14
12
-
13
- * Add a timeout to the validator
14
- * Give the documentation some love
15
-
16
- == 0.2.1 / 2009-09-14
17
-
18
- * Removed Ambethia namespace, and restructured classes a bit
19
- * Added an example rails app in the example-rails branch
20
-
21
- == 0.2.0 / 2009-09-12
22
-
23
- * RecaptchaOptions AJAX API Fix
24
- * Added 'cucumber' as a test environment to skip
25
- * Ruby 1.9 compat fixes
26
- * Added option :message => 'Custom error message' to verify_recaptcha
27
- * Removed dependency on ActiveRecord constant
28
- * Add I18n
29
-
30
- == 0.1.0 / 2008-2-8
31
-
32
- * 1 major enhancement
33
- * Initial Gem Release
data/Gemfile DELETED
@@ -1,3 +0,0 @@
1
- source 'https://rubygems.org'
2
-
3
- gemspec
data/README.rdoc DELETED
@@ -1,146 +0,0 @@
1
- = reCAPTCHA
2
-
3
- Author:: Jason L Perry (http://ambethia.com)
4
- Copyright:: Copyright (c) 2007-2013 Jason L Perry
5
- License:: {MIT}[http://creativecommons.org/licenses/MIT/]
6
- Info:: http://github.com/ambethia/recaptcha
7
- Bugs:: http://github.com/ambethia/recaptcha/issues
8
-
9
- This plugin adds helpers for the {reCAPTCHA API}[http://recaptcha.net]. In your
10
- views you can use the +recaptcha_tags+ method to embed the needed javascript,
11
- and you can validate in your controllers with +verify_recaptcha+.
12
-
13
- Beforehand you need to configure Recaptcha with your custom private and public
14
- key. You may find detailed examples below. Exceptions will be raised if you
15
- call these methods and the keys can't be found.
16
-
17
- == Rails Installation
18
-
19
- reCAPTCHA for Rails > 3.0, add this to your Gemfile:
20
-
21
- gem "recaptcha", :require => "recaptcha/rails"
22
-
23
- Rails apps below 3.0 are no longer supported, but you can install an older
24
- release and view it's README.
25
-
26
- == Setting up your API Keys
27
-
28
- There are multiple ways to setup your reCAPTCHA API key once you
29
- {obtain}[http://recaptcha.net/whyrecaptcha.html] a pair.
30
-
31
- === Recaptcha.configure
32
-
33
- You may use the block style configuration. The following code could be placed
34
- into a +config/initializers/recaptcha.rb+ when used in a Rails project.
35
-
36
- Recaptcha.configure do |config|
37
- config.public_key = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
38
- config.private_key = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
39
- config.proxy = 'http://myproxy.com.au:8080'
40
- end
41
-
42
- This way, you may also set additional options to fit recaptcha into your
43
- deployment environment.
44
-
45
- == Recaptcha#with_configuration
46
-
47
- If you want to temporarily overwrite the configuration you set with `Recaptcha.configure` (when testing, for example), you can use a `Recaptcha#with_configuration` block:
48
-
49
- Recaptcha.with_configuration(:public_key => '12345') do
50
- # Do stuff with the overwritten public_key.
51
- end
52
-
53
- === Heroku & Shell environment
54
-
55
- Or, you can keep your keys out of your code base by exporting the following
56
- environment variables. You might do this in the .profile/rc, or equivalent for
57
- the user running your application. This would also be the preffered method
58
- in an Heroku deployment.
59
-
60
- export RECAPTCHA_PUBLIC_KEY = '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
61
- export RECAPTCHA_PRIVATE_KEY = '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
62
-
63
- === Per call
64
-
65
- You can also pass in your keys as options at runtime, for example:
66
-
67
- recaptcha_tags :public_key => '6Lc6BAAAAAAAAChqRbQZcn_yyyyyyyyyyyyyyyyy'
68
-
69
- and later,
70
-
71
- verify_recaptcha :private_key => '6Lc6BAAAAAAAAKN3DRm6VA_xxxxxxxxxxxxxxxxx'
72
-
73
- This option might be useful, if the same code base is used for multiple
74
- reCAPTCHA setups.
75
-
76
- == To use 'recaptcha'
77
-
78
- Add +recaptcha_tags+ to each form you want to protect. Place it where you want the recaptcha widget to appear.
79
-
80
- Example:
81
-
82
- <%= form_for @foo do |f| %>
83
- # ... additional lines truncated for brevity ...
84
- <%= recaptcha_tags %>
85
- # ... additional lines truncated for brevity ...
86
- <% end %>
87
-
88
- And, add +verify_recaptcha+ logic to each form action that you've protected.
89
-
90
- === +recaptcha_tags+
91
-
92
- Some of the options available:
93
-
94
- <tt>:ssl</tt>:: Uses secure http for captcha widget (default +false+, but can be changed by setting +config.use_ssl_by_default+)
95
- <tt>:noscript</tt>:: Include <noscript> content (default +true+)
96
- <tt>:display</tt>:: Takes a hash containing the +theme+ and +tabindex+ options per the API. (default +nil+), options: 'red', 'white', 'blackglass', 'clean', 'custom'
97
- <tt>:ajax</tt>:: Render the dynamic AJAX captcha per the API. (default +false+)
98
- <tt>:public_key</tt>:: Your public API key, takes precedence over the ENV variable (default +nil+)
99
- <tt>:error</tt>:: Override the error code returned from the reCAPTCHA API (default +nil+)
100
-
101
- You can also override the html attributes for the sizes of the generated +textarea+ and +iframe+
102
- elements, if CSS isn't your thing. Inspect the source of +recaptcha_tags+ to see these options.
103
-
104
- === +verify_recaptcha+
105
-
106
- This method returns +true+ or +false+ after processing the parameters from the reCAPTCHA widget. Why
107
- isn't this a model validation? Because that violates MVC. You can use it like this, or how ever you
108
- like. Passing in the ActiveRecord object is optional, if you do--and the captcha fails to verify--an
109
- error will be added to the object for you to use.
110
-
111
- Some of the options available:
112
-
113
- <tt>:model</tt>:: Model to set errors
114
- <tt>:attribute</tt>:: Model attribute to receive errors (default :base)
115
- <tt>:message</tt>:: Custom error message
116
- <tt>:private_key</tt>:: Your private API key, takes precedence over the ENV variable (default +nil+).
117
- <tt>:timeout</tt>:: The number of seconds to wait for reCAPTCHA servers before give up. (default +3+)
118
-
119
- respond_to do |format|
120
- if verify_recaptcha(:model => @post, :message => "Oh! It's error with reCAPTCHA!") && @post.save
121
- # ...
122
- else
123
- # ...
124
- end
125
- end
126
-
127
- == I18n support
128
- reCAPTCHA passes two types of error explanation to a linked model. It will use the I18n gem
129
- to translate the default error message if I18n is available. To customize the messages to your locale,
130
- add these keys to your I18n backend:
131
-
132
- <tt>recaptcha.errors.verification_failed</tt>:: error message displayed if the captcha words didn't match
133
- <tt>recaptcha.errors.recaptcha_unreachable</tt>:: displayed if a timeout error occured while attempting to verify the captcha
134
-
135
- Also you can translate API response errors to human friendly by adding translations to the locale (+config/locales/en.yml+):
136
-
137
- en:
138
- recaptcha:
139
- errors:
140
- incorrect-captcha-sol: 'Fail'
141
-
142
- == TODO
143
- * Remove Rails/ActionController dependencies
144
- * Framework agnostic
145
- * Add some helpers to use in before_filter and what not
146
- * Better documentation