tollwerk/tw-antibot

消灭垃圾邮件机器人! — TYPO3 表单的无 CAPTCHA 垃圾邮件安全

安装: 12

依赖关系: 0

建议者: 0

安全: 0

星标: 6

关注者: 4

分支: 0

开放问题: 2

类型:typo3-cms-extension

v1.0.0 2016-12-21 18:34 UTC

This package is auto-updated.

Last update: 2024-09-17 13:05:15 UTC


README

Antibot (tw_antibot) 是一个如何为 TYPO3 项目的表单提供无 CAPTCHA 安全性的快速概念验证。它可以与 Fluid 模板 和/或 formhandler 表单 一起使用。对于扩展目前既没有很好的测试也没有很好的文档,我们表示歉意。欢迎反馈和建议!

此扩展受到了 2012/2013 年 Karl Groves 的文章 "无 CAPTCHA 安全性" 的深刻启发,并支持他的 BotSmasher API 作为外部黑名单。

安装

将扩展安装到您的 composer 模式 TYPO3 安装中

cd /path/to/site/root
composer require tollwerk/tw-antibot

只需将 Antibot 的静态 TypoScript 添加到您的主模板中,然后开始配置所需的选项。

Antibot 支持 ChromePhp 将日志记录到您的 Chrome 控制台。在安装过程中,Composer 将自动拉入 ChromePhp。

配置

Antibot 具有以下检查功能。所有选项都可以使用常量编辑器进行配置。

内部禁止(黑名单)

客户端可以通过以下方式加入黑名单:

  • IP 地址(《plugin.tx_twantibot.settings.banning.ip》)
  • 电子邮件地址(《plugin.tx_twantibot.settings.banning.email》)

您可以根据需要配置客户端是永久加入黑名单还是仅在一定时间内加入黑名单。使用 TYPO3 的计划任务中提供的 Extbase-CommandController-Task 定期删除过期的黑名单记录。

外部禁止

Antibot 支持 BotSmasher 识别已知的垃圾邮件发送者/欺诈地址。您需要 BotSmasher API 密钥 才能使用此选项(《plugin.tx_twantibot.settings.botsmasher》)。

蜜罐字段

您可以为表单配置一个或多个蜜罐字段(《plugin.tx_twantibot.settings.honeypot》)来添加。蜜罐字段通常对人类用户是隐藏的(例如,通过 CSS display: none)和/或明确标记为不要填写。如果提交了蜜罐字段的值,则很可能是机器人提交。一些建议

  • 将蜜罐放在提交按钮之后。
  • 像典型的表单字段一样命名它们,例如 email 和/或 name(它们将自动获得 antibot_*[] 前缀)。
  • 确保它们不是 type="hidden",因为机器人通常会忽略这些。

会话令牌

为了防止表单被劫持和外部提交,会话令牌可能会被考虑。(plugin.tx_twantibot.settings.session)

提交时间

Antibot可能会考虑您表单提交所需的时间,以识别机器人提交(plugin.tx_twantibot.settings.time)。您可以指定

  • **初次提交的最小提交时间**
  • **所有后续提交的最小时间**(例如,当有验证错误时)
  • 以及**最大时间**。

提交方法向量

您可能可以限制表单的提交方法向量(plugin.tx_twantibot.settings.order

  • GET-GET
  • GET-POST
  • POST-GET
  • POST-POST

第一部分指定在您的表单最初显示时必须使用的HTTP方法,而任何(重新)提交都必须使用第二种方法。

Extbase / Fluid 示例

{namespace ab=Tollwerk\TwAntibot\ViewHelpers}

<section id="comment-form">
	<h1>Write new comment</h1>
	
	<!-- Antibot access check and validation -->
	<f:if condition="{ab:access.granted(argument: 'newComment')}">
		<f:then>
			<f:form action="create" name="newComment" object="{newComment}">
			 	<p>Required fields are followed by <strong><abbr title="required">*</abbr></strong>.</p>
			 	<div class="form-row type-text">
			 		<label for="name">Name <strong><abbr title="required">*</abbr></strong></label>
					<f:form.textfield id="name" property="name" />
					<f:form.validationResults for="newComment.name"><f:if condition="{validationResults.flattenedErrors}"><p><f:for each="{validationResults.errors}" as="error">{error.code}: {error}</f:for></p></f:if></f:form.validationResults>	
			 	</div>
				
				<!-- Additional form fields ... -->

				<div class="form-row type-submit">
					<f:form.submit class="" value="Create new" />
					
					<!-- Antibot armor fields (place after submit button) -->
					<ab:armor/>
					
				</div>
			</f:form>
		</f:then>
		<f:else>
			<p>You are denied access to this form due to spam restrictions. If you think this is an error, please contact <f:link.email email="test@test.com">test@test.com</f:link.email>.</p>
		</f:else>
	</f:if>
</section>

请注意,确保涉及发送表单的控制操作是**不可缓存的**是至关重要的!为此,请将它们包含在插件注册的非缓存操作列表中(ext_localconf.php

\TYPO3\CMS\Extbase\Utility\ExtensionUtility::configurePlugin(
	'Tollwerk.' . $_EXTKEY,
	'Comments',
	array(
		'Comment' => 'list, show, new, create',
	),
	// non-cacheable actions
	array(
		'Comment' => 'new, create',
	)
);

Formhandler 示例

TypoScript

plugin.Tx_Formhandler.settings.predef.contact {
	name					= Contact
	templateFile 			= FLUIDTEMPLATE
	templateFile {
		file				= fileadmin/.../contact.html
	}
	
	initInterceptors.1 {
		class				= Tollwerk\TwAntibot\Formhandler\Interceptor
		config {
			antibot {
				token		= customToken
				# ...
			}
			templateFile	< plugin.Tx_Formhandler.settings.predef.contact.templateFile 
		}
	}
	
	markers{
		antibotArmor		= USER_INT
		antibotArmor {
			userFunc		= Tollwerk\TwAntibot\Formhandler\Utility->armor
			
			# Custom config should be the same as above
			antibot			< plugin.Tx_Formhandler.settings.predef.contact.initInterceptors.1.config.antibot
		}
	}
}

HTML 模板

<!-- ###TEMPLATE_FORM1### begin -->
<form method="post" id="###formID###" enctype="multipart/form-data">
	<fieldset><!-- Form fields ... --></fieldset>
	<div>
		###field_langId###
		###field_submit_contact###
		
		<!-- Antibot armor fields (custom marker) -->
		###antibotArmor###
	</div>
</form>
<!-- ###TEMPLATE_FORM1### end -->

<!-- ###TEMPLATE_ANTIBOT### begin -->
<p>You are denied access to this form due to spam restrictions. If you think this is an error, please contact <a href="mailto:info@manuscript-facsimiles.com">info@manuscript-facsimiles.com</a>.</p>
<!-- ###TEMPLATE_ANTIBOT### end -->

法律

版权所有 © 2015 tollwerk GmbH / Joschi Kuphal (joschi@kuphal.net / @jkphl)。svg-sprite 在 MIT 许可证的条款下授权。