aboutsummaryrefslogtreecommitdiffstats
path: root/include/auth.php
diff options
context:
space:
mode:
authorKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2014-12-14 01:22:52 +0100
committerKlaus Weidenbach <Klaus.Weidenbach@gmx.net>2014-12-14 01:50:56 +0100
commit233903c84428b9322eaea94bf22f6ae972e44332 (patch)
tree15ef2df5a74cd6f9ad587417979ed7129dfb81d8 /include/auth.php
parent7a19bd7fb35f5b41db81e9a2397ea085a165a94a (diff)
downloadvolse-hubzilla-233903c84428b9322eaea94bf22f6ae972e44332.tar.gz
volse-hubzilla-233903c84428b9322eaea94bf22f6ae972e44332.tar.bz2
volse-hubzilla-233903c84428b9322eaea94bf22f6ae972e44332.zip
Add security logger to RedDAV.
Some smaller clean ups whitepsaces and tabs, use PHP_EOL, Doxygen, etc.
Diffstat (limited to 'include/auth.php')
-rw-r--r--include/auth.php22
1 files changed, 18 insertions, 4 deletions
diff --git a/include/auth.php b/include/auth.php
index 94c64e58d..545fbe8c9 100644
--- a/include/auth.php
+++ b/include/auth.php
@@ -41,6 +41,9 @@ function nuke_session() {
/**
* @brief Verify login credentials.
*
+ * If system <i>authlog</i> is set a log entry will be added for failed login
+ * attempts.
+ *
* @param string $email
* The email address to verify.
* @param string $pass
@@ -88,14 +91,25 @@ function account_verify_password($email, $pass) {
if($record['account_flags'] & ACCOUNT_PENDING)
logger('Account is pending. account_flags = ' . $record['account_flags']);
- // Also log failed logins to a separate auth log to reduce overhead for server side intrusion prevention
- $authlog = get_config('system', 'authlog');
- if ($authlog)
- @file_put_contents($authlog, datetime_convert() . ':' . session_id() . ' ' . $error . "\n", FILE_APPEND);
+ log_failed_login($error);
return null;
}
+/**
+ * @brief Log failed logins to a separate auth log.
+ *
+ * Can be used to reduce overhead for server side intrusion prevention, like
+ * parse the authlog file with something like fail2ban, OSSEC, etc.
+ *
+ * @param string $errormsg
+ * Error message to display for failed login.
+ */
+function log_failed_login($errormsg) {
+ $authlog = get_config('system', 'authlog');
+ if ($authlog)
+ @file_put_contents($authlog, datetime_convert() . ':' . session_id() . ' ' . $errormsg . PHP_EOL, FILE_APPEND);
+}
/**
* Inline - not a function