Lite & fast micro PHP abuse library that is **easy to use**.

Overview

Utopia Abuse

Build Status Total Downloads Discord

Utopia framework abuse library is simple and lite library for managing application usage limits. This library is aiming to be as simple and easy to learn and use. This library is maintained by the Appwrite team.

Although this library is part of the Utopia Framework project it is dependency free, and can be used as standalone with any other PHP project or framework.

Getting Started

Install using composer:

composer require utopia-php/abuse

Time Limit Abuse

The time limit abuse allow each key (action) to be performed [X] times in given time frame. This adapter uses a MySQL / MariaDB to store usage attempts. Before using it create the table schema as documented in this repository (./data/schema.sql)

<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\TimeLimit;

// Limit login attempts to 10 time in 5 minutes time frame
$adapter    = new TimeLimit('login-attempt-from-{{ip}}', 10, (60 * 5), function () {/* init and return PDO connection... */});

$adapter
    ->setNamespace('namespace') // DB table namespace
    ->setParam('{{ip}}', '127.0.0.1')
;

$abuse      = new Abuse($adapter);

// Use vars to resolve adapter key

if(!$abuse->check()) {
    throw new Exception('Service was abused!'); // throw error and return X-Rate limit headers here
}

ReCaptcha Abuse

The ReCaptcha abuse controller is using Google ReCaptcha service to detect when service is being abused by bots. To use this adapter you need to create an API key from the Google ReCaptcha service admin console.

<?php

require_once __DIR__ . '/../../vendor/autoload.php';

use Utopia\Abuse\Abuse;
use Utopia\Abuse\Adapters\ReCaptcha;

// Limit login attempts to 10 time in 5 minutes time frame
$adapter    = new ReCaptcha('secret-api-key', $_POST['g-recaptcha-response'], $_SERVER['REMOTE_ADDR']);
$abuse      = new Abuse($adapter);

if(!$abuse->check()) {
    throw new Exception('Service was abused!'); // throw error and return X-Rate limit headers here
}

Notice: The code above is for example purpose only. It is always recommended to validate user input before using it in your code. If you are using a load balancer or any proxy server you might need to get user IP from the HTTP_X_FORWARDE‌​D_FOR header.

System Requirements

Utopia Framework requires PHP 7.4 or later. We recommend using the latest PHP version whenever possible.

Authors

Eldad Fux

Copyright and license

The MIT License (MIT) http://www.opensource.org/licenses/mit-license.php

Comments
  • Upgrade our issue templates to use GitHub issue forms ✍️

    Upgrade our issue templates to use GitHub issue forms ✍️

    Introduction

    GitHub has recently rolled out a public beta for their issue forms feature. This would allow you to create interactive issue templates and validate them 🤯.

    Appwrite currently uses the older issue template format. Your task is to create GitHub issue forms for this repository. Please use Appwrite's issue templates as a reference for this PR.

    Tasks summary:

    • [ ] Fork & clone this repository
    • [ ] Prepare bug report issue form in .github/ISSUE_TEMPLATE/bug.yaml
    • [ ] Prepare documentation issue form in .github/ISSUE_TEMPLATE/documentation.yaml
    • [ ] Prepare feature request issue form in .github/ISSUE_TEMPLATE/feature.yaml
    • [ ] Push changes to master and test issue forms on your fork
    • [ ] Submit pull request

    If you need any help, reach out to us on our Discord server.

    Are you ready to work on this issue? 🤔 Let us know, and we will assign it to you 😊

    Happy Appwriting!

    good first issue hacktoberfest 
    opened by Meldiron 5
  •  CONTRIBUTING.md #2099

    CONTRIBUTING.md #2099

    Help us add the Contributing Guidelines to abuse repository #2099. I hope it is alright if there is any issue please do let me know.Above is the reference issue which I was assigned.

    hacktoberfest-accepted 
    opened by harshita214 1
  • Update permissions

    Update permissions

    • Update to $permissions from $read/$write
    • Update database version (dev stability - needs a coordinated merge with https://github.com/utopia-php/database/pull/161)
    opened by abnegate 0
  • Feat: use namespace as table prefix

    Feat: use namespace as table prefix

    Appwrite is now moving all previous databases in the DBMS into a single top-level database. This PR supports this change by using the namespace as a table prefix for the abuse collection.

    This PR also removes support for PHP <8.

    Testing: Since this PR only affects creation, only test setup was adjusted.

    opened by kodumbeats 0
  • Feat: Implement linter

    Feat: Implement linter

    What does this PR do?

    Implemented linter for the repository

    Related PRs and Issues

    appwrite/appwrite/issues/4359

    Have you read the Contributing Guidelines on issues?

    Yes

    hacktoberfest-accepted 
    opened by PMohanJ 5
  • 🚀 Feature: hCaptcha support

    🚀 Feature: hCaptcha support

    🔖 Feature description

    Support hCaptcha additionally to ReCaptcha for keeping bots away.

    🎤 Pitch

    hCaptcha is a more privacy friendly alternative to ReCaptcha.

    👀 Have you spent some time to check if this issue has been raised before?

    • [X] I checked and didn't find similar issue

    🏢 Have you read the Code of Conduct?

    enhancement help wanted good first issue 
    opened by gorootde 1
Releases(0.16.0)
  • 0.16.0(Oct 31, 2022)

    What's Changed

    • composer upgrade database 0.28.* by @fogelito in https://github.com/utopia-php/abuse/pull/36

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.15.0...0.16.0

    Source code(tar.gz)
    Source code(zip)
  • 0.15.0(Oct 31, 2022)

    What's Changed

    • upgrade database to 0.27 by @lohanidamodar in https://github.com/utopia-php/abuse/pull/35

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.14.0...0.15.0

    Source code(tar.gz)
    Source code(zip)
  • 0.14.0(Oct 14, 2022)

    What's Changed

    • upgrade database by @lohanidamodar in https://github.com/utopia-php/abuse/pull/32

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.13.1...0.14.0

    Source code(tar.gz)
    Source code(zip)
  • 0.13.1(Sep 7, 2022)

    What's Changed

    • database 0.25.* tag change by @fogelito in https://github.com/utopia-php/abuse/pull/30

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.13.0...0.13.1

    Source code(tar.gz)
    Source code(zip)
  • 0.13.0(Sep 6, 2022)

    What's Changed

    • Bump database by @abnegate in https://github.com/utopia-php/abuse/pull/29

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.12.0...0.13.0

    Source code(tar.gz)
    Source code(zip)
  • 0.12.0(Aug 27, 2022)

    What's Changed

    • chore: bump database by @christyjacob4 in https://github.com/utopia-php/abuse/pull/28

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.11.0...0.12.0

    Source code(tar.gz)
    Source code(zip)
  • 0.11.0(Aug 19, 2022)

    What's Changed

    • feat: update database by @christyjacob4 in https://github.com/utopia-php/abuse/pull/27

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.10.0...0.11.0

    Source code(tar.gz)
    Source code(zip)
  • 0.10.0(Aug 17, 2022)

    What's Changed

    • Abuse Timezone filter by @fogelito in https://github.com/utopia-php/abuse/pull/26

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.9.0...0.10.0

    Source code(tar.gz)
    Source code(zip)
  • 0.9.0(Aug 15, 2022)

    What's Changed

    • Refactor auth skips by @abnegate in https://github.com/utopia-php/abuse/pull/21
    • Refactor permissions by @abnegate in https://github.com/utopia-php/abuse/pull/25

    New Contributors

    • @abnegate made their first contribution in https://github.com/utopia-php/abuse/pull/21

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.8.0...0.9.0

    Source code(tar.gz)
    Source code(zip)
  • 0.8.0(Aug 8, 2022)

    What's Changed

    • Unixtime to datetime changes by @fogelito in https://github.com/utopia-php/abuse/pull/20

    New Contributors

    • @fogelito made their first contribution in https://github.com/utopia-php/abuse/pull/20

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.7.0...0.8.0

    Source code(tar.gz)
    Source code(zip)
  • 0.7.0(Dec 27, 2021)

    What's Changed

    • Added guides by @Meldiron in https://github.com/utopia-php/abuse/pull/14
    • Upgrades issue templates to use GitHub issue forms ✍️ by @drph4nt0m in https://github.com/utopia-php/abuse/pull/13
    • Feat: use namespace as table prefix by @kodumbeats in https://github.com/utopia-php/abuse/pull/18

    New Contributors

    • @Meldiron made their first contribution in https://github.com/utopia-php/abuse/pull/14
    • @drph4nt0m made their first contribution in https://github.com/utopia-php/abuse/pull/13

    Full Changelog: https://github.com/utopia-php/abuse/compare/0.6.3...0.7.0

    Source code(tar.gz)
    Source code(zip)
  • 0.6.3(Aug 16, 2021)

  • 0.6.2(Aug 13, 2021)

  • 0.6.1(Aug 3, 2021)

  • 0.6.0(Aug 1, 2021)

  • 0.5.0(Jun 28, 2021)

  • 0.4.2(Jun 23, 2021)

  • 0.4.1(Jun 5, 2021)

  • 0.4.0(Mar 17, 2021)

  • 0.3.1(Dec 21, 2020)

  • 0.3.0(Dec 17, 2020)

  • 0.2.2(Oct 23, 2020)

  • 0.2.1(Jun 20, 2020)

Owner
utopia
Lite & fast micro PHP framework and libraries that are **easy to learn and use**.
utopia
A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast!

A powerful yet easy-to-use PHP micro-framework designed to help you build dynamic and robust Web applications - fast! Condensed in a single ~65KB file

Bong Cosca 2.6k Dec 30, 2022
AbuseIO is a toolkit to receive, process, correlate and notify about abuse reports received by network operators, typically hosting and access providers.

AbuseIO - Abusemanagement tools AbuseIO is a toolkit to receive, process, correlate and notify end users about abuse reports received by network opera

AbuseIO 189 Dec 6, 2022
Framework X is a simple and fast micro framework based on PHP

Framework X is a simple and fast micro framework based on PHP. I've created a simple CRUD application to understand how it works. I used twig and I created a custom middleware to handle PUT, DELETE methods.

Mahmut Bayri 6 Oct 14, 2022
Framework X – the simple and fast micro framework for building reactive web applications that run anywhere.

Framework X Framework X – the simple and fast micro framework for building reactive web applications that run anywhere. Quickstart Documentation Tests

Christian Lück 620 Jan 7, 2023
Easy to use, fast extendable small PHP Framework, like the one you ever missed. The skeleton-APP

About Tufu-Framework Easy to use, fast extendable PHP Framework, like the one you ever missed. Features included such as: Twig and extensions. Fast ro

Giacomo Barbalinardo 0 Jul 2, 2022
Fast and easy PHP framework

Español | English Fácil, rápido y en español (Or should I say fast and easy?) Bienvenidos a KumbiaPHP Framework Versión 1 Manual en construcción de la

KumbiaPHP Framework 281 Jan 2, 2023
Simple, fast and secure PHP Framework with easy integration.

simple-php-framework Simple, fast and secure PHP Framework with easy integration.

winact 2 Nov 23, 2021
Fast and easy PHP framework

Español | English Fácil, rápido y en español (Or should I say fast and easy?) Bienvenidos a KumbiaPHP Framework Versión 1 Manual en construcción de la

KumbiaPHP Framework 280 Dec 26, 2022
Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Slim Framework Slim is a PHP micro-framework that helps you quickly write simple yet powerful web applications and APIs. Installation It's recommended

Slim Framework 11.5k Jan 4, 2023
A tiny, yet powerful, PHP micro-framework.

Equip Framework A tiny and powerful PHP micro-framework created and maintained by the engineering team at When I Work. Attempts to be PSR-1, PSR-2, PS

Equip 118 Jun 24, 2022
An extensible micro-framework for PHP

What is Flight? Flight is a fast, simple, extensible framework for PHP. Flight enables you to quickly and easily build RESTful web applications. requi

Mike Cao 2.5k Dec 30, 2022
A resource-oriented micro PHP framework

Bullet Bullet is a resource-oriented micro PHP framework built around HTTP URIs. Bullet takes a unique functional-style approach to URL routing by par

Vance Lucas 415 Dec 27, 2022
a micro mvc framework for php

micro-mvc-php a micro mvc framework for php Config your Web url in .env . lifecycle All request proccess by index.php Autoload files include in bootst

Amiranbari 6 Jul 9, 2022
An application for building micro-services in PHP ^8.

Restolia An application for building micro-services in PHP ^8. Install composer create-project restolia/restolia my-app Services Each service lives i

null 1 May 1, 2022
The Slim PHP micro framework paired with Laravel's Illuminate Database toolkit.

Slim & Eloquent The Slim PHP micro framework paired with Laravel's Illuminate Database toolkit. Getting started # Download composer curl -s https://ge

Kyle Ladd 111 Jul 23, 2022
⚡ Micro API using Phalcon Framework

Micro App (Rest API) ⚡ Micro API using Phalcon PHP Framework. PHPDocs I. Requirements A Laptop ?? Docker (docker-compose*) Makefile (cli) II. Installa

Neutrapp 7 Aug 6, 2021
Mutexes for Micro-Framework HLEB

Use of mutexes in a project (including projects based on the HLEB micro framework) The use of mutexes is worthwhile in cases, when access to any code

Foma Tuturov 1 Oct 11, 2022
A curated list of awesome tutorials and other resources for the Slim micro framework

Awesome Slim A curated list of awesome tutorials and other resources for the Slim micro framework Table of Contents Essentials Tutorials Packages and

Sawyer Charles 466 Dec 8, 2022
Plates Template Integration for Slim micro framework 3

Plates Template Integration for Slim micro framework 3 Render your Slim 3 application views using Plates template engine. Install Via Composer $ compo

Projek XYZ 26 Feb 5, 2022