Limiting Incorrect Logins

Limiting Incorrect Logins

by David Price -
Number of replies: 7
Is there a way to limit incorrect logins in Moodle, say 5 attemps and your blocked for 30 mins.. etc
Average of ratings: -
In reply to David Price

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to Deleted user

Re: Limiting Incorrect Logins

by John Sanga -
I agree. We are interested in the same. Have you received any suggestions?
In reply to John Sanga

This forum post has been removed

The content of this forum post has been removed and can no longer be accessed.
In reply to David Price

Re: Limiting Incorrect Logins

by Iñaki Arenaza -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers

As far as I know, there's no way to do that without modifying the login code (and I'm not aware of anyone doing something like that so far).

Saludos, Iñaki.

In reply to David Price

Re: Limiting Incorrect Logins

by ETH Zürich -
you can limit it, but not under time, because the value is added to the session, so you can limit the login over time if you modify the session time smile but it affects over all site browsing because the session would be destroyed faster like online banking.

to limit the number, in lib/moodlelib.php function:

function update_login_count() {

global $SESSION;

$max_logins = 10; //change it to whatever you like

if (empty($SESSION->logincount)) {
$SESSION->logincount = 1;
} else {
$SESSION->logincount++;
}

if ($SESSION->logincount > $max_logins) {
unset($SESSION->wantsurl);
print_error('errortoomanylogins');
}
}





In reply to ETH Zürich

Re: Limiting Incorrect Logins

by Hubert Chathi -
Storing this information in the session is unreliable -- it is easily circumvented by deleting (or simply not using) the session cookie. For example, it would not work against many scripted brute-force attempts.

To do this reliably, the login count should be stored in the database, associated with either the user that they are trying to log in as, or the IP address that they are coming from. (Of course, associating it with the user may convert an attempted-login attack into a DoS attack. And using the IP address doesn't protect against distributed attempts.)
In reply to Hubert Chathi

Re: Limiting Incorrect Logins

by Tim Hunt -
Picture of Core developers Picture of Documentation writers Picture of Particularly helpful Moodlers Picture of Peer reviewers Picture of Plugin developers
Moodle does log failed logins in the database. Surely that is how the features that lets you notify admins if there are too many failed login attempts works.

Anyway, look at the existing code, before you start re-inventing everything from scratch. There should already be some stuff to build on.