MaxSem has uploaded a new change for review.
https://gerrit.wikimedia.org/r/177938
Change subject: Restrict response API to 2 submissions per minute
......................................................................
Restrict response API to 2 submissions per minute
Change-Id: I4b55804531d457ceb46820389685c98df5913de3
---
M WikiGrok.php
M includes/api/ApiResponse.php
2 files changed, 8 insertions(+), 1 deletion(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/WikiGrok
refs/changes/38/177938/1
diff --git a/WikiGrok.php b/WikiGrok.php
index 96a1147..0fe8572 100644
--- a/WikiGrok.php
+++ b/WikiGrok.php
@@ -48,6 +48,9 @@
$wgConfigRegistry['wikigrok'] = 'GlobalVarConfig::newInstance';
+// Flood protection: no more than 2 responses per minute per user
+$wgRateLimits['wikigrokresponse'] = array( '*' => array( 2, 60 ) );
+
/**
* Configuration settings
diff --git a/includes/api/ApiResponse.php b/includes/api/ApiResponse.php
index 202bce7..ec8c43f 100644
--- a/includes/api/ApiResponse.php
+++ b/includes/api/ApiResponse.php
@@ -21,6 +21,11 @@
public function execute() {
$profileSection = new \ProfileSection( __METHOD__ );
+ $user = $this->getUser();
+ if ( $user->pingLimiter( 'wikigrokresponse' ) ) {
+ $this->dieUsage( 'Too many responses over a short
timespan', 'ratelimited' );
+ }
+
$params = $this->extractRequestParams();
$claims = $this->extractClaims( $params['claims'] );
@@ -30,7 +35,6 @@
$this->dieUsage( 'You must specify at least one claim',
'no_claims' );
}
- $user = $this->getUser();
$baseEvent = array(
'pageId' => $params['page_id'],
'userToken' => $params['user_token'],
--
To view, visit https://gerrit.wikimedia.org/r/177938
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4b55804531d457ceb46820389685c98df5913de3
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/WikiGrok
Gerrit-Branch: master
Gerrit-Owner: MaxSem <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits