Skip to content

Added Captcha setting to Ghost Admin #22405

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
merged 3 commits into from
Mar 7, 2025
Merged

Added Captcha setting to Ghost Admin #22405

merged 3 commits into from
Mar 7, 2025

Conversation

sam-lord
Copy link
Contributor

@sam-lord sam-lord commented Mar 6, 2025

ref BAE-400

This is only enabled when the lab setting is at the moment.

We should be able configure the keys from the front end too for self-hosters, we can add that next.

Copy link
Contributor

coderabbitai bot commented Mar 6, 2025

Walkthrough

The pull request introduces a new CAPTCHA validation toggle within the SpamFilters component. Changes include integrating a new Toggle element and an associated handler to update the state of the captcha setting based on user interaction, as well as updating import statements and helper functions such as getSettingValue. Additionally, the PR modifies the public API endpoint for settings to explicitly return a captcha_enabled property with a default value when the feature flag is inactive. Other updates span the settings serializer, migration scripts, default settings JSON schema, configuration defaults, and the public settings cache, ensuring that the captcha_enabled property is consistently integrated across the codebase.

Possibly related PRs

  • Added Captcha to data attribute forms #22049: The changes in the main PR, which enhance the SpamFilters component with a captcha toggle feature, are related to the retrieved PR that integrates CAPTCHA functionality into data attribute forms, as both involve modifications to the handling and management of CAPTCHA settings.
  • Refactored Captcha to simplify usage #22180: The changes in the main PR, which introduce a captcha toggle feature in the SpamFilters component, are related to the retrieved PR that refactors the hCaptcha component, as both involve modifications to the handling and management of captcha settings within the application.
  • Use Captcha middleware in members API #22014: The changes in the main PR, which enhance the SpamFilters component with a captcha toggle feature, are related to the retrieved PR that modifies the getCaptchaSettings function to manage captcha settings, as both involve the handling of the captcha_enabled property and its integration into the application.

Suggested labels

deploy-to-staging, browser-tests

Suggested reviewers

  • aileen
  • lsinger

Warning

There were issues while running some tools. Please review the errors and either fix the tool’s configuration or disable the tool if it’s a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/admin-x-settings/src/components/settings/advanced/SpamFilters.tsx

Oops! Something went wrong! :(

ESLint: 8.44.0

ESLint couldn't find the plugin "eslint-plugin-react-hooks".

(The package "eslint-plugin-react-hooks" was not found when loaded as a Node module from the directory "/apps/admin-x-settings".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-react-hooks@latest --save-dev

The plugin "eslint-plugin-react-hooks" was referenced from the config file in "apps/admin-x-settings/.eslintrc.cjs".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7a659855f1c19d471173d8bd4b89cd0b40e34f24 and b89c2dc.

⛔ Files ignored due to path filters (2)
  • ghost/core/test/e2e-api/content/__snapshots__/settings.test.js.snap is excluded by !**/*.snap
  • ghost/core/test/e2e-api/shared/__snapshots__/version.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (10)
  • apps/admin-x-settings/src/components/settings/advanced/SpamFilters.tsx (4 hunks)
  • ghost/core/core/server/api/endpoints/settings-public.js (1 hunks)
  • ghost/core/core/server/api/endpoints/utils/serializers/input/settings.js (1 hunks)
  • ghost/core/core/server/data/migrations/versions/5.111/2025-03-05-16-36-39-add-captcha-setting.js (1 hunks)
  • ghost/core/core/server/data/schema/default-settings/default-settings.json (1 hunks)
  • ghost/core/core/shared/config/defaults.json (1 hunks)
  • ghost/core/core/shared/settings-cache/public.js (1 hunks)
  • ghost/core/test/e2e-api/content/settings.test.js (0 hunks)
  • ghost/core/test/unit/server/data/exporter/index.test.js (1 hunks)
  • ghost/core/test/unit/server/data/schema/integrity.test.js (1 hunks)
💤 Files with no reviewable changes (1)
  • ghost/core/test/e2e-api/content/settings.test.js
🚧 Files skipped from review as they are similar to previous changes (9)
  • ghost/core/test/unit/server/data/exporter/index.test.js
  • ghost/core/core/shared/config/defaults.json
  • ghost/core/core/server/api/endpoints/utils/serializers/input/settings.js
  • ghost/core/core/server/api/endpoints/settings-public.js
  • ghost/core/test/unit/server/data/schema/integrity.test.js
  • ghost/core/core/server/data/schema/default-settings/default-settings.json
  • ghost/core/core/shared/settings-cache/public.js
  • ghost/core/core/server/data/migrations/versions/5.111/2025-03-05-16-36-39-add-captcha-setting.js
  • apps/admin-x-settings/src/components/settings/advanced/SpamFilters.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Setup

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

github-actions bot commented Mar 6, 2025

It looks like this PR contains a migration 👀
Here's the checklist for reviewing migrations:

General requirements

  • ⚠️ Tested on the staging database servers
  • Satisfies idempotency requirement (both up() and down())
  • Does not reference models
  • Filename is in the correct format (and correctly ordered)
  • Targets the next minor version
  • All code paths have appropriate log messages
  • Uses the correct utils
  • Contains a minimal changeset
  • Does not mix DDL/DML operations
  • Tested in MySQL and SQLite

Schema changes

  • Both schema change and related migration have been implemented
  • For index changes: has been performance tested for large tables
  • For new tables/columns: fields use the appropriate predefined field lengths
  • For new tables/columns: field names follow the appropriate conventions
  • Does not drop a non-alpha table outside of a major version

Data changes

  • Mass updates/inserts are batched appropriately
  • Does not loop over large tables/datasets
  • Defends against missing or invalid data
  • For settings updates: follows the appropriate guidelines

@github-actions github-actions bot added the migration [pull request] Includes migration for review label Mar 6, 2025
@sam-lord sam-lord added deploy-to-staging Optionally deploy PR to staging browser-tests labels Mar 6, 2025
@sam-lord sam-lord merged commit 9150e67 into main Mar 7, 2025
75 of 78 checks passed
@sam-lord sam-lord deleted the captcha-settings branch March 7, 2025 00:32
@Ghost-Slimer
Copy link

Deployed to staging with ID: 3266

How does this work?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
browser-tests deploy-to-staging Optionally deploy PR to staging migration [pull request] Includes migration for review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants