Skip to content
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

feat: setting to allow disabling sfs lookup #2

Merged
merged 2 commits into from
Nov 23, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions extend.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,10 @@

(new Extend\Settings())
->default('fof-anti-spam.regionalEndpoint', 'closest')
->default('fof-anti-spam.sfs-lookup', true)
->default('fof-anti-spam.username', false)
->default('fof-anti-spam.ip', true)
->default('fof-anti-spam.email', true)
->default('fof-anti-spam.emailhash', false)
->default('fof-anti-spam.frequency', 5)
->default('fof-anti-spam.confidence', 50.0)
Expand Down
6 changes: 6 additions & 0 deletions js/src/admin/components/AntiSpamSettingsPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ export default class AntiSpamSettingsPage extends ExtensionPage {
help: app.translator.trans('fof-anti-spam.admin.settings.stopforumspam.regional_endpoint_help'),
default: 'closest',
})}
{this.buildSettingComponent({
type: 'boolean',
setting: 'fof-anti-spam.sfs-lookup',
label: app.translator.trans('fof-anti-spam.admin.settings.stopforumspam.sfs_lookup_label'),
help: app.translator.trans('fof-anti-spam.admin.settings.stopforumspam.sfs_lookup_help'),
})}
{this.buildSettingComponent({
type: 'boolean',
setting: 'fof-anti-spam.username',
Expand Down
3 changes: 3 additions & 0 deletions locale/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ fof-anti-spam:
email_hash_label: Use hashed email address
email_hash_help: Pass a MD5 hash of the email address should you wish to not pass the email address itself. This method bypasses all blacklists, normalisation and obfuscation bypass checks.

sfs_lookup_label: Lookup registrations
sfs_lookup_help: If enabled, we will check the StopForumSpam database when a new user registers on your forum. If the user is found (username, IP address, email) and that data point is enabled along with the SFS confidence level reaching your defined level, they will be prevented from completing their registration.

forum:
message:
spam: Your info has been marked as spam.
Expand Down
5 changes: 5 additions & 0 deletions src/StopForumSpam.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ private function call(string $url, array $data): ResponseInterface
*/
public function shouldPreventLogin(array $data, ?string $provider = null, ?array $providerData = null): bool
{
// If we don't have sfs lookup enabled, we return false early.
if (! (bool) $this->settings->get('fof-anti-spam.sfs-lookup')) {
return false;
}

$data['json'] = 1;

$hashEmail = (bool) $this->settings->get('fof-anti-spam.emailhash');
Expand Down
Loading