All Projects → anyx → LoginGateBundle

anyx / LoginGateBundle

Licence: other
No description or website provided.

Programming Languages

PHP
23972 projects - #3 most used programming language
Twig
543 projects
shell
77523 projects

Projects that are alternatives of or similar to LoginGateBundle

LiipSoapRecorderBundle
[DEPRECATED] Recorder/Player for SOAP communications
Stars: ✭ 12 (-78.95%)
Mutual labels:  symfony-bundle
queue-bundle
Symfony Queue Bundle
Stars: ✭ 31 (-45.61%)
Mutual labels:  symfony-bundle
workflower-bundle
A Symfony bundle for Workflower
Stars: ✭ 23 (-59.65%)
Mutual labels:  symfony-bundle
awsBundle
Symfony AWS Bundle (supports Symfony 2, 3 and 4)
Stars: ✭ 18 (-68.42%)
Mutual labels:  symfony-bundle
phpfastcache-bundle
The symfony 3/Flex bundle for PhpFastCache integrating a phpfastcache service, a twig cache tag and a powerfull cache profiler integrated to the symfony profile
Stars: ✭ 19 (-66.67%)
Mutual labels:  symfony-bundle
wordpress-bundle
Use Wordpress and Symfony together using a Symfony bundle
Stars: ✭ 30 (-47.37%)
Mutual labels:  symfony-bundle
GmailBruterV2
Simple tool written in python3 to perform limited brute-force attacks on gmail accounts.
Stars: ✭ 264 (+363.16%)
Mutual labels:  brute-force-attacks
pentesting-framework
Pentesting Framework is a bundle of penetration testing tools, Includes - security, pentesting, hacking and many more.
Stars: ✭ 90 (+57.89%)
Mutual labels:  brute-force-attacks
facade-bundle
Support Facades for Symfony service
Stars: ✭ 17 (-70.18%)
Mutual labels:  symfony-bundle
SpBundle
SAML2 SP Symfony Bundle based on LightSAML
Stars: ✭ 62 (+8.77%)
Mutual labels:  symfony-bundle
firebase-bundle
A Symfony Bundle for the Firebase PHP Admin SDK
Stars: ✭ 112 (+96.49%)
Mutual labels:  symfony-bundle
socketio
No description or website provided.
Stars: ✭ 23 (-59.65%)
Mutual labels:  symfony-bundle
ContentfulBundle
Symfony Bundle for the Contentful SDK.
Stars: ✭ 29 (-49.12%)
Mutual labels:  symfony-bundle
breadcrumb-bundle
Symfony bundle for easy breadcrumbs management
Stars: ✭ 26 (-54.39%)
Mutual labels:  symfony-bundle
TelegramBotBundle
Symfony Telegram Bot Bundle
Stars: ✭ 51 (-10.53%)
Mutual labels:  symfony-bundle
CmsBundle
Super-lightweight CMS bundle for Symfony
Stars: ✭ 52 (-8.77%)
Mutual labels:  symfony-bundle
OpcacheBundle
Displays the PHP OPcache status in the Symfony profiler toolbar.
Stars: ✭ 21 (-63.16%)
Mutual labels:  symfony-bundle
Brutegram
Instagram multi-bruteforce Platfrom
Stars: ✭ 183 (+221.05%)
Mutual labels:  brute-force-attacks
WPCracker
WordPress pentest tool
Stars: ✭ 34 (-40.35%)
Mutual labels:  brute-force-attacks
Gmail-Hack
Adapted for send emails from Termux.
Stars: ✭ 61 (+7.02%)
Mutual labels:  brute-force-attacks

LoginGateBundle

Build Status Latest Stable Version Total Downloads License Donate

This bundle detects brute-force attacks on Symfony applications. It then will disable login for attackers for a certain period of time. This bundle also provides special events to execute custom handlers when a brute-force attack is detected.

Compatibility

The bundle is since version 1.0 compatible with Symfony 5.

Installation

Add this bundle via Composer:

composer require anyx/login-gate-bundle

Configuration:

Add in config/packages/login_gate.yml:

# config/packages/login_gate.yaml

login_gate:
    storages: ['orm'] # Attempts storages. Available storages: ['orm', 'session', 'mongodb']
    options:
        max_count_attempts: 3
        timeout: 600 #Ban period
        watch_period: 3600 #Only for databases storage. Period of actuality attempts

⚠️ Username resolver (optional).

Since Symfony does not provide a common way to retrieve passed username from LoginFailureEvent for every possible authentication scenario, by default this bundle is trying to retrieve username from _username parameter in request's form data.

It means, that if you are using different authentication scenario (json_login, for example), users with same ip addresses will be indistinguishable. To prevent this, you probably should create own username resolver and register it in username_resolver option:

<?php

namespace App\Service;

use Anyx\LoginGateBundle\Service\UsernameResolverInterface;
use Symfony\Component\HttpFoundation\Request;

/**
 * Username resolver for json login
 */
class UsernameResolver implements UsernameResolverInterface
{
    public function resolve(Request $request)
    {
        $requestData = json_decode($request->getContent(), true);

        return is_array($requestData) && array_key_exists('username', $requestData) ? $requestData['username'] : null;
    }
}
# config/packages/login_gate.yaml
login_gate:
    storages: ['orm'] # Attempts storages. Available storages: ['orm', 'session', 'mongodb']
    options:
        max_count_attempts: 3
        timeout: 600 #Ban period
        watch_period: 3600 #Only for databases storage. Period of actuality attempts
    username_resolver: App\Service\UsernameResolver

Register event handler (optional).

services:
      acme.brute_force_listener:
          class: Acme\BestBundle\Listener\BruteForceAttemptListener
          tags:
              - { name: kernel.event_listener, event: security.brute_force_attempt, method: onBruteForceAttempt }

Usage

For classic login form authentication we can check count login attempts before showing form:

namespace App\Controller;

use Anyx\LoginGateBundle\Service\BruteForceChecker;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Http\Authentication\AuthenticationUtils;

class SecurityController extends AbstractController
{
    /**
     * @Route("/login", name="login")
     */
    public function formLogin(AuthenticationUtils $authenticationUtils, BruteForceChecker $bruteForceChecker, Request $request): Response
    {
        if (!$bruteForceChecker->canLogin($request)) {
            return new Response('Too many login attempts');
        }

        $error = $authenticationUtils->getLastAuthenticationError();

        $lastUsername = $authenticationUtils->getLastUsername();

        return $this->render('security/login.html.twig', ['last_username' => $lastUsername, 'error' => $error]);
    }
}

Also there is ability to clear login attempts for request (it happens after successful authentication by default):

$this->bruteForceChecker->getStorage()->clearCountAttempts($request, $username);

For more examples take a look at the tests.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].