A Ruby on Rails application demonstrating Byebot integration.
cd integrations/rails
bundle installEdit the constants in app/controllers/sessions_controller.rb and app/services/byebot_validator.rb:
BYEBOT_API_KEY = "your-api-key"
BYEBOT_SITE_KEY = "your-site-key"bundle exec rails server -p 4242Visit http://localhost:4242
-
Frontend: The widget is loaded via
<script src="https://challenge.byebot.de/ray/widget.js">. A div withclass="captcha-widget"anddata-sitekeyattribute renders the CAPTCHA. -
Token Submission: On verification, the widget adds a hidden
byebot-tokenfield to the form. -
Server Validation: POST the token to
/validate_token:
uri = URI.parse("https://challenge.byebot.de/validate_token")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path)
request["Content-Type"] = "application/json"
request.body = { api_key: BYEBOT_API_KEY, token: token }.to_json
response = http.request(request)
# 200 OK = valid tokenapp/controllers/sessions_controller.rb- Login form controllerapp/services/byebot_validator.rb- Token validation serviceapp/views/sessions/new.html.erb- Login form with CAPTCHA widgetapp/views/sessions/create.html.erb- Success page