-
Notifications
You must be signed in to change notification settings - Fork 136
Feature/account security #2677
New issue
Have a question about this project? Sign up for a free GitHub ac 8000 count 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
Draft
ideadude
wants to merge
29
commits into
dev
Choose a base branch
from
feature/account-security
base: dev
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Feature/account security #2677
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
1bd5220
adding spam settings and functions
ideadude 5cea8ac
Wired up the spam checker.
ideadude d746c27
Checkout controller is always constructed, so fixed.
ideadude bda2763
undoing changes here
ideadude 6eff6d1
adding captcha settings, needs js and code
ideadude 2def872
Merge branch 'dev' into feature/account-security
ideadude 96975bf
Merge branch 'dev' into feature/account-security
brianhogg 07fa4bb
Merge branch 'dev' into feature/account-security
brianhogg 93ab869
Getting test to pass with mock settings for saving test.
brianhogg c728d91
Formatting. Calling turnstile "secret" key vs. private to match docs.
brianhogg afd9630
Fixing check if spam protection is enabled, since the value is "yes" …
brianhogg f5ee8b5
Added turnstile and wired up the settings. Can override with a define…
brianhogg 42914a0
Rename to secret key to match verbiage. Adding abspath check.
brianhogg 9da28b7
WIP: reCAPTCHA v3
brianhogg 9e43e9d
Only load if on front-end. Add textdomain.
brianhogg 39522d7
WIP: POC for recaptcha on the checkout form.
brianhogg 9291e97
Checks captcha on submit of a lifterlms form. Doesn't display notice …
brianhogg 5f34852
Avoid rendering on the back-end. Adding logs via filter.
brianhogg 37dccef
Print notices on the free enroll form so an error can be shown if cap…
brianhogg ecc57b0
Fix for test.
brianhogg 15dad54
Fix warning when visiting the logs page for the first time.
brianhogg e575ed2
Removing log.
brianhogg fdd37a0
Changelogs.
brianhogg 250a943
Merge branch 'dev' into feature/account-security
brianhogg b8315b7
Refactor into a base captcha class.
brianhogg 3ab6c9e
Moving to a separate Security settings tab.
brianhogg 0aac1ef
Conditional show/hide of the captcha settings.
brianhogg 88a1712
Adding hint text.
brianhogg 5b30db2
WIP: Handling when the checkout form exists, and both are trying to s…
brianhogg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
significance: minor | ||
type: added | ||
entry: Option for automatically blocking checkout spam. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
significance: minor | ||
type: added | ||
entry: Support for Turnstile and Recaptcha v3 with checkout and registration forms. |
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
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
150 changes: 150 additions & 0 deletions
150
includes/admin/settings/class.llms.settings.security.php
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
<?php | ||
/** | ||
* Admin Settings Page, Security Tab | ||
* | ||
* @package LifterLMS/Admin/Settings/Classes | ||
* | ||
* @since 1.0.0 | ||
* @version 7.5.0 | ||
*/ | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Admin Settings Page, Security Tab class | ||
* | ||
* @since [version] | ||
*/ | ||
class LLMS_Settings_Security extends LLMS_Settings_Page { | ||
|
||
/** | ||
* Settings identifier | ||
* | ||
* @var string | ||
*/ | ||
public $id = 'security'; | ||
|
||
/** | ||
* Get settings array | ||
* | ||
* @since [version] | ||
* | ||
* @return array | ||
*/ | ||
public function get_settings() { | ||
$account_settings = array( | ||
array( | ||
'class' => 'top', | ||
'id' => 'course_account_options', | ||
'type' => 'sectionstart', | ||
), | ||
array( | ||
'title' => __( 'Website Security & Spam Prevention', 'lifterlms' ), | ||
'type' => 'title', | ||
'id' => 'security_and_spam_options_title', | ||
), | ||
array( | ||
'autoload' => false, | ||
'default' => '', | ||
'id' => 'lifterlms_captcha', | ||
'desc' => __( 'Choose a captcha service to require at checkout.', 'lifterlms' ), | ||
'title' => __( 'Captcha', 'lifterlms' ), | ||
'type' => 'select', | ||
'options' => array( | ||
'' => __( 'None', 'lifterlms' ), | ||
'recaptcha' => __( 'reCAPTCHA', 'lifterlms' ), | ||
'turnstile' => __( 'Turnstile', 'lifterlms' ), | ||
), | ||
'class' => 'llms-conditional-controller', | ||
'custom_attributes' => array( | ||
'data-controls-recaptcha' => '#lifterlms_recaptcha_site_key,#lifterlms_recaptcha_secret_key', | ||
'data-controls-turnstile' => '#lifterlms_turnstile_site_key,#lifterlms_turnstile_secret_key', | ||
), | ||
), | ||
array( | ||
'autoload' => false, | ||
'default' => '', | ||
'id' => 'lifterlms_recaptcha_site_key', | ||
'desc' => 'Requires reCAPTCHA v3 keys. <a href="https://lifterlms.com/docs/recaptcha" target="_blank">Learn More</a>.', | ||
'title' => __( 'reCAPTCHA v3 Site Key', 'lifterlms' ), | ||
'type' => 'text', | ||
'custom_attributes' => array( | ||
'data-controller' => 'captcha', | ||
'data-value-is' => 'recaptcha', | ||
), | ||
), | ||
array( | ||
'autoload' => false, | ||
'default' => '', | ||
'id' => 'lifterlms_recaptcha_secret_key', | ||
'desc' => '', | ||
'title' => __( 'reCAPTCHA v3 Secret Key', 'lifterlms' ), | ||
'type' => 'text', | ||
'custom_attributes' => array( | ||
'data-controller' => 'captcha', | ||
'data-value-is' => 'recaptcha', | ||
), | ||
), | ||
array( | ||
'autoload' => false, | ||
'default' => '', | ||
'id' => 'lifterlms_turnstile_site_key', | ||
'desc' => 'Requires Cloudflare Turnstile keys. <a href="https://lifterlms.com/docs/turnstile" target="_blank">Learn More</a>.', | ||
'title' => __( 'Turnstile Site Key', 'lifterlms' ), | ||
'type' => 'text', | ||
'custom_attributes' => array( | ||
'data-controller' => 'captcha', | ||
'data-value-is' => 'turnstile', | ||
), | ||
), | ||
array( | ||
'autoload' => false, | ||
'default' => '', | ||
'id' => 'lifterlms_turnstile_secret_key', | ||
'desc' => '', | ||
'title' => __( 'Turnstile Secret Key', 'lifterlms' ), | ||
'type' => 'text', | ||
'custom_attributes' => array( | ||
'data-controller' => 'captcha', | ||
'data-value-is' => 'turnstile', | ||
), | ||
), | ||
array( | ||
'autoload' => false, | ||
'default' => 'no', | ||
'id' => 'lifterlms_spam_protection', | ||
'desc' => __( 'Block IPs from checkout if there are more than 10 failures within 15 minutes.', 'lifterlms' ), | ||
'title' => __( 'Spam Protection', 'lifterlms' ), | ||
'type' => 'checkbox', | ||
), | ||
array( | ||
'id' => 'security_and_spam_options_end', | ||
'type' => 'sectionend', | ||
), | ||
); | ||
|
||
/** | ||
* Filters the account settings. | ||
* | ||
* The dynamic portion of this filter `{$this->id}` refers to the unique ID for the settings page. | ||
* | ||
* @since [version] | ||
* | ||
* @param array $account_settings The account page settings. | ||
*/ | ||
return apply_filters( "lifterlms_{$this->id}_settings", $account_settings ); | ||
} | ||
|
||
/** | ||
* Retrieve the page label. | ||
* | ||
* @since [version] | ||
* | ||
* @return string | ||
*/ | ||
protected function set_label() { | ||
return __( 'Security', 'lifterlms' ); | ||
} | ||
} | ||
|
||
return new LLMS_Settings_Security(); |
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
Oops, something went wrong.
Oops, something went wrong.
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
2EA4
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.
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
Copilot Autofix
AI about 21 hours ago
To fix the issue, the value retrieved from the
data-controls
attribute should be sanitized or escaped before being passed to the$()
function. Specifically, jQuery's$.escapeSelector
method can be used to escape any special characters in the selector string. This ensures that the input is treated strictly as a CSS selector and not as HTML or JavaScript.The fix involves wrapping the
$( this ).attr( 'data-controls' )
call with$.escapeSelector
before passing it to$()
. This change should be made on line 87.).attr( 'data-controls' ) ).closest( 'tr' );