idi_captcha_generator 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +35 -0
- data/Rakefile +4 -0
- data/idi_captcha_generator.gemspec +39 -0
- data/lib/idi_captcha_generator/version.rb +5 -0
- data/lib/idi_captcha_generator.rb +35 -0
- data/sig/idi_captcha_generator.rbs +4 -0
- metadata +55 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 0c925011e76551ff10bb4c00ae7073702f79c93f2bf75361daefd5972283868c
|
4
|
+
data.tar.gz: 1f2f378e7654a703f7f8ca1266fbc3b4c8194d5bd49cab9a53bc60567779c801
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: e39bdefeae6f60ca36a0f6e75cdb741236e75ef09a0148c27255024d19013fabc9a96f90574926d8cb4d21a10e9f6951ee2d08e98dc466ef540d62e5cfd56d15
|
7
|
+
data.tar.gz: 8e5815e4ad3b6ea272b976b7da0366fbf4007aae2c2a997e11c34157b57762f0c5c1b5a8837783d08028173f3a487955a7ca2eecbfbe751ed88f39bba1ce6ab1
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# IdiCaptchaGenerator
|
2
|
+
|
3
|
+
TODO: Delete this and the text below, and describe your gem
|
4
|
+
|
5
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/idi_captcha_generator`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
|
10
|
+
|
11
|
+
Install the gem and add to the application's Gemfile by executing:
|
12
|
+
|
13
|
+
```bash
|
14
|
+
bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
15
|
+
```
|
16
|
+
|
17
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
18
|
+
|
19
|
+
```bash
|
20
|
+
gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
|
21
|
+
```
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/idi_captcha_generator.
|
data/Rakefile
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/idi_captcha_generator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "idi_captcha_generator"
|
7
|
+
spec.version = IdiCaptchaGenerator::VERSION
|
8
|
+
spec.authors = ["Idrees Ibrahim"]
|
9
|
+
spec.email = ["idrees.ibrahim@pitv.gov.pk"]
|
10
|
+
|
11
|
+
# Summary and Description
|
12
|
+
spec.summary = "A lightweight and secure CAPTCHA generator for Ruby on Rails applications, designed to provide an additional layer of security against bots and automated submissions. This gem generates unique image-based questions and answers that are easy for users to solve but challenging for scripts."
|
13
|
+
spec.description = "The idi_captcha_generator gem provides a customizable CAPTCHA solution tailored for high-traffic applications, ensuring that only legitimate users can access features like sign-up and login forms. By leveraging image-based questions, it prevents automated systems from bypassing security measures. This gem is particularly useful in environments where external services (like Google reCAPTCHA) cannot be used due to network restrictions. With simple implementation steps, you can integrate robust CAPTCHA functionality into your Rails application, enhancing its security without sacrificing user experience.
|
14
|
+
Feel free to modify these texts to better fit your vision for the gem! If you need further assistance or adjustments, just let me know!"
|
15
|
+
|
16
|
+
spec.homepage = "https://rubygems.org/gems/idi_captcha_generator"
|
17
|
+
spec.required_ruby_version = ">= 2.6.0"
|
18
|
+
|
19
|
+
# Meta Information
|
20
|
+
spec.metadata['base_path'] = File.expand_path('..', __FILE__)
|
21
|
+
# Uncomment and modify as needed
|
22
|
+
# spec.metadata["allowed_push_host"] = "https://rubygems.org/gems/idi_sms"
|
23
|
+
# spec.metadata["homepage_uri"] = spec.homepage
|
24
|
+
# spec.metadata["source_code_uri"] = "https://github.com/idreesibrahim/idi_sms"
|
25
|
+
# spec.metadata["changelog_uri"] = "https://github.com/idreesibrahim/idi_sms/blob/main/CHANGELOG.md"
|
26
|
+
|
27
|
+
# Specify which files should be added to the gem when it is released.
|
28
|
+
spec.files = Dir.chdir(__dir__) do
|
29
|
+
`git ls-files -z`.split("\x0").reject do |f|
|
30
|
+
(File.expand_path(f) == __FILE__) ||
|
31
|
+
f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile])
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
spec.bindir = "exe"
|
36
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
37
|
+
spec.require_paths = ["lib"]
|
38
|
+
spec.license = "Nonstandard"
|
39
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# lib/captcha_generator.rb
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require_relative "idi_captcha_generator/version"
|
5
|
+
require 'rmagick' # For image manipulation
|
6
|
+
|
7
|
+
module CaptchaGenerator
|
8
|
+
def self.generate_captcha
|
9
|
+
# Randomly generate a simple math question
|
10
|
+
num1 = rand(1..10)
|
11
|
+
num2 = rand(1..10)
|
12
|
+
answer = num1 + num2
|
13
|
+
question = "#{num1} + #{num2} = ?"
|
14
|
+
|
15
|
+
# Create an image with RMagick
|
16
|
+
image = Magick::Image.new(200, 100) {
|
17
|
+
self.background_color = 'white'
|
18
|
+
}
|
19
|
+
draw = Magick::Draw.new
|
20
|
+
draw.annotate(image, 0, 0, 0, 0, question) do
|
21
|
+
draw.font = 'Helvetica'
|
22
|
+
draw.fill = 'black'
|
23
|
+
draw.pointsize = 32
|
24
|
+
draw.gravity = Magick::CenterGravity
|
25
|
+
end
|
26
|
+
draw.draw(image)
|
27
|
+
|
28
|
+
# Save image to a temporary location
|
29
|
+
image_path = Rails.root.join('tmp', "captcha_#{Time.now.to_i}.png")
|
30
|
+
image.write(image_path)
|
31
|
+
|
32
|
+
{ question: question, answer: answer, image_path: image_path }
|
33
|
+
end
|
34
|
+
class Error < StandardError; end
|
35
|
+
end
|
metadata
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: idi_captcha_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Idrees Ibrahim
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2024-10-16 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: |-
|
14
|
+
The idi_captcha_generator gem provides a customizable CAPTCHA solution tailored for high-traffic applications, ensuring that only legitimate users can access features like sign-up and login forms. By leveraging image-based questions, it prevents automated systems from bypassing security measures. This gem is particularly useful in environments where external services (like Google reCAPTCHA) cannot be used due to network restrictions. With simple implementation steps, you can integrate robust CAPTCHA functionality into your Rails application, enhancing its security without sacrificing user experience.
|
15
|
+
Feel free to modify these texts to better fit your vision for the gem! If you need further assistance or adjustments, just let me know!
|
16
|
+
email:
|
17
|
+
- idrees.ibrahim@pitv.gov.pk
|
18
|
+
executables: []
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- README.md
|
23
|
+
- Rakefile
|
24
|
+
- idi_captcha_generator.gemspec
|
25
|
+
- lib/idi_captcha_generator.rb
|
26
|
+
- lib/idi_captcha_generator/version.rb
|
27
|
+
- sig/idi_captcha_generator.rbs
|
28
|
+
homepage: https://rubygems.org/gems/idi_captcha_generator
|
29
|
+
licenses:
|
30
|
+
- Nonstandard
|
31
|
+
metadata:
|
32
|
+
base_path: "/home/idrees/rorapps/idi_captcha_generator"
|
33
|
+
post_install_message:
|
34
|
+
rdoc_options: []
|
35
|
+
require_paths:
|
36
|
+
- lib
|
37
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: 2.6.0
|
42
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - ">="
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
requirements: []
|
48
|
+
rubygems_version: 3.5.6
|
49
|
+
signing_key:
|
50
|
+
specification_version: 4
|
51
|
+
summary: A lightweight and secure CAPTCHA generator for Ruby on Rails applications,
|
52
|
+
designed to provide an additional layer of security against bots and automated submissions.
|
53
|
+
This gem generates unique image-based questions and answers that are easy for users
|
54
|
+
to solve but challenging for scripts.
|
55
|
+
test_files: []
|