-
Notifications
You must be signed in to change notification settings - Fork 41
Enhance Security, Testing, and Code Compatibility (#26) #109
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
* feat: add invisible reCAPTCHA to enhance security * Add GitHub account verification for user registration Introduced `GithubAccountVerifier` service to validate the existence of GitHub accounts via API. Integrated the verification into the user model with appropriate validations and error handling. Updated tests and the registration form to ensure a valid GitHub username is required during user registration. * feat: implement recaptcha using cloudflare-turnstile gem * fix rubocop offenses * setup master key * add mocha and change `enum` definition in user model - add mocha gem to load and provide the mockk and stubs methods for testing - Changed enum definition in the user model from using a keyword argument to a positional argument to keep code compatible with future Rails 8 * Add recaptcha, mocha, gh verification, and change `enum` definition in user model - add invisible reCAPTCHA using cloudflare-turnstile gem to enhance security - add mocha gem to load and provide the mockk and stubs methods for testing - Changed enum definition in the user model from using a keyword argument to a positional argument to keep code compatible with future Rails 8 - Add GitHub account verification for user registration - Introduced `GithubAccountVerifier` service to validate the existence of GitHub accounts via API. Integrated the verification into the user model with appropriate validations and error handling. Updated tests and the registration form to ensure a valid GitHub username is required during user registration.
3 tasks
This reverts commit d6f5654.
This reverts commit b911579.
…Encryptor error" This reverts commit 1e90070.
* feat: Add Turnstile keys for test and development * refactor: Update GitHub Actions to use GITHUB_OUTPUT Replace deprecated `set-output` command with `$GITHUB_OUTPUT` for setting step outputs * refactor: replace cloudflare-turnstile gem with manual verification in sessions and registrations - Removed dependency on cloudflare-turnstile gem - Implemented direct API verification for Turnstile - Integrated validation into SessionsController#create(login) and RegistrationsController#create (sign up) - Improved error handling with localized messages * refactor: remove JS bundling, switch to importmap, and cleanup dependencies - Replaced `jsbundling-rails` with `importmap-rails` - Removed unnecessary JavaScript dependencies (e.g., autoprefixer, esbuild, postcss, tailwindcss) - Updated Turnstile controller for improved handling and compatibility - Adjusted app layout and asset imports to support importmap * chore: add docs and update CI workflow dependencies and environment setup - Upgrade `actions/checkout` to v5 - Update Node.js version to 22 and install Yarn globally - Add system dependency installation for `libpq-dev` - Configure environment variables for Postgres in tests - Update test commands to streamline setup and execution * chore: simplify CI workflow by removing unused Node.js and JS dependencies - Dropped Node.js setup, Yarn installation, and related caching steps - Streamlined test setup and execution steps to focus on Ruby environment * chore: update asset pipeline configuration and CI workflow - Add CSS builds directory to asset paths - Update manifest to exclude JS compilation via Sprockets - Modify CI workflow tasks to align with asset pipeline changes * Revert "chore: update asset pipeline configuration and CI workflow" This reverts commit f08918b. * Revert "chore: simplify CI workflow by removing unused Node.js and JS dependencies" This reverts commit 4891ccd. * Revert "chore: add docs and update CI workflow dependencies and environment setup" This reverts commit cc76d07. * Revert "refactor: remove JS bundling, switch to importmap, and cleanup dependencies" This reverts commit 2b2689a. * chore: upgrade Ruby to 3.4.4 and enhance Turnstile controller - Updated Ruby version across configurations (Gemfile, .ruby-version, .tool-versions, and Gemfile.lock). - Refactored Turnstile Stimulus controller for improved rendering, defaults, and error handling. - Registered the Turnstile controller in JavaScript controllers. * fix linting issues
* feat: Add Turnstile keys for test and development * refactor: Update GitHub Actions to use GITHUB_OUTPUT Replace deprecated `set-output` command with `$GITHUB_OUTPUT` for setting step outputs * refactor: replace cloudflare-turnstile gem with manual verification in sessions and registrations - Removed dependency on cloudflare-turnstile gem - Implemented direct API verification for Turnstile - Integrated validation into SessionsController#create(login) and RegistrationsController#create (sign up) - Improved error handling with localized messages * refactor: remove JS bundling, switch to importmap, and cleanup dependencies - Replaced `jsbundling-rails` with `importmap-rails` - Removed unnecessary JavaScript dependencies (e.g., autoprefixer, esbuild, postcss, tailwindcss) - Updated Turnstile controller for improved handling and compatibility - Adjusted app layout and asset imports to support importmap * chore: add docs and update CI workflow dependencies and environment setup - Upgrade `actions/checkout` to v5 - Update Node.js version to 22 and install Yarn globally - Add system dependency installation for `libpq-dev` - Configure environment variables for Postgres in tests - Update test commands to streamline setup and execution * chore: simplify CI workflow by removing unused Node.js and JS dependencies - Dropped Node.js setup, Yarn installation, and related caching steps - Streamlined test setup and execution steps to focus on Ruby environment * chore: update asset pipeline configuration and CI workflow - Add CSS builds directory to asset paths - Update manifest to exclude JS compilation via Sprockets - Modify CI workflow tasks to align with asset pipeline changes * Revert "chore: update asset pipeline configuration and CI workflow" This reverts commit f08918b. * Revert "chore: simplify CI workflow by removing unused Node.js and JS dependencies" This reverts commit 4891ccd. * Revert "chore: add docs and update CI workflow dependencies and environment setup" This reverts commit cc76d07. * Revert "refactor: remove JS bundling, switch to importmap, and cleanup dependencies" This reverts commit 2b2689a. * chore: upgrade Ruby to 3.4.4 and enhance Turnstile controller - Updated Ruby version across configurations (Gemfile, .ruby-version, .tool-versions, and Gemfile.lock). - Refactored Turnstile Stimulus controller for improved rendering, defaults, and error handling. - Registered the Turnstile controller in JavaScript controllers. * fix linting issues * fix: disable "Create Account" button and update styles
adamswonder
approved these changes
Aug 22, 2025
Collaborator
adamswonder
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jolly good! Tested different scenarios
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Enhance Security, Testing, and Code Compatibility
This pull request introduces several key enhancements focused on improving application security, enabling more robust testing, and ensuring future Rails compatibility.
Key Changes & Improvements:
Cloudflare Turnstile Integration for Enhanced Security:
rails-cloudflare-turnstilegem.before_actionand includes appropriate error handling for failed challenges.GitHub Account Verification for User Registration: TEMPORARY!!
GithubAccountVerifierservice responsible for validating the existence of GitHub usernames via the GitHub API.Usermodel with a custom validation to ensure only valid GitHub accounts can be registered.presence: trueanduniqueness: truevalidations for thegithub_usernamefield.devise/registrations/new.html.erb) to include the GitHub username field.GithubAccountVerifierservice have been updated/added to ensure correct functionality and error handling.Improved Testing Capabilities with Mocha:
mochagem to the test environment.GithubAccountVerifier), allowing us to simulate API responses without making actual network calls.Rails 8 Compatibility Update for
UserModelenum:enumdefinition for theroleattribute in theUsermodel.enum role: { ... }) to the new positional argument syntax (enum :role, { ... }).How to Test/Verify:
User Registration (Manual):
user--name).if Rails.env.production?from thebefore_actioninRegistrationsControllerto see it in action).Run Test Suite:
bundle exec rails testto ensure all existing and new tests pass, especially for theUsermodel andGithubAccountVerifierservice.Code Review:
enumsyntax inapp/models/user.rb.app/services/github_account_verifier.rband its corresponding test file.app/controllers/users/registrations_controller.rbfor Turnstile integration andapp/views/devise/registrations/new.html.erbfor the Turnstile tag and GitHub username field.