Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fail2ban support #35

Merged
36 commits merged into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
f39f8a6
(feat): add audit module to defaults, add patching of audit module
Feb 1, 2024
ff665ce
(fix): change company name, add namespace
Feb 1, 2024
33538a3
(feat): add collection dependencies
Feb 1, 2024
1d7b4af
(feat): specify github branch for galaxy
Feb 1, 2024
2d9d98b
(feat): add necessary strip of 1
Feb 1, 2024
233f2e2
(feat): add fail2ban filter for icingaweb2 audit log
Feb 1, 2024
1742abb
(feat): add installation of fail2ban to role
Feb 1, 2024
68d03d1
(feat): instead of patching it live, use our own fork of the audit mo…
Feb 1, 2024
d4dede1
Remove 401 tag
Feb 8, 2024
4902d39
(chore): fix linting errors and use correct ansible-lint action
Feb 8, 2024
87e6ec7
(fix): remove patch as we use our own fork
Feb 8, 2024
ba9fdde
(fix): add dependencies for roles and collections
Feb 8, 2024
2348638
Revert "(fix): add dependencies for roles and collections"
Feb 8, 2024
677f780
(chore): fix linting errors in installation.yml
Feb 8, 2024
20d5846
(fix): add missing collection
Feb 8, 2024
dce8618
(chore): fix linting errors in configuration.yml
Feb 8, 2024
bd38bfb
(chore): fix linting errors in main.yml
Feb 8, 2024
f774d88
(fix): Migrate terrific RST README to glorious Markdown
Feb 8, 2024
f09da77
Company was renamed
Feb 13, 2024
4a599c4
Role was moved to a new namespace
Feb 13, 2024
5893949
(docs): move dependencies up into requirements section
Feb 13, 2024
beed16e
Fix image urls
Feb 13, 2024
bd54f0b
Company was renamed
Feb 13, 2024
38c9b8b
Change link for images
Feb 13, 2024
68cdc4f
(docs): change name of role
Feb 13, 2024
02857d3
(ci): dont checkout into subfolder
Feb 13, 2024
c949920
(meta): fix name of dependency in meta file
Feb 13, 2024
55f72c2
(chore): remove tests inside role itself
Feb 13, 2024
0424295
(lint): Fix MISSING STARTING SPACE IN COMMENT
Feb 13, 2024
3a5bebc
(fix): ALL NAMES SHOULD START WITH UPPERCASE LETTER
Feb 13, 2024
f14a4cd
(fix): USE FQCN FOR BUILTIN MODULE ACTIONS
Feb 13, 2024
7929aa8
(fix): use string for version
Feb 13, 2024
d2ebaa8
(fix): change spacing of commented modules
Feb 13, 2024
0aaa7a0
(fix): add a no-changed-when noqa to let us provision icingaweb2 on f…
Feb 13, 2024
b9eb8d1
(fix): let yamllint just use the '.yamllint' configfile
Feb 13, 2024
bf2f27f
(fix): .ansible-lint config is yaml
Feb 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,15 +93,23 @@ icinga2_web_managed_config_files:

icinga2_web_modules: []
#- name: graphite
# url: 'https://github.com/icinga/icingaweb2-module-graphite.git'
# version: master
#- name: ipl
# url: 'https://github.com/icinga/icingaweb2-module-ipl.git'
# version: v0.5.0
#- name: incubator
# url: 'https://github.com/icinga/icingaweb2-module-incubator.git'
# version: v0.5.0
#- name: reactbundle
# url: 'https://github.com/icinga/icingaweb2-module-reactbundle.git'
# version: v0.7.0
#- name: director
# url: 'https://github.com/icinga/icingaweb2-module-director.git'
# version: v1.7.2
#- name: audit
# url: 'https://github.com/adfinis/icingaweb2-module-audit.git'
# version: master
s3lph marked this conversation as resolved.
Show resolved Hide resolved

# Icingaweb2 LDAP authentication
# For further information, consult the official icingaweb2 documentation at
Expand Down
67 changes: 67 additions & 0 deletions files/0001-icingaweb2-module-audit-remote-ip-logging.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From 3bf6f47910834e4ddd9c7fb4bf085daed5ab515a Mon Sep 17 00:00:00 2001
This conversation was marked as resolved.
Show resolved Hide resolved
From: airbone95 <airbone95@users.noreply.github.com>
Date: Mon, 25 May 2020 08:37:14 +0200
Subject: [PATCH] added ip-logging

---
application/controllers/LogController.php | 1 +
application/views/scripts/log/index.phtml | 3 +++
library/Audit/ProvidedHook/AuditLog.php | 3 ++-
library/Audit/ProvidedHook/AuditStream.php | 3 ++-
4 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/application/controllers/LogController.php b/application/controllers/LogController.php
index cc0d110..d0d2c4d 100644
--- a/application/controllers/LogController.php
+++ b/application/controllers/LogController.php
@@ -36,6 +36,7 @@ public function indexAction()
'fields' => '/(?<!.)' // ^ can't handle multilines, don't ask *me* why this works
. '(?<datetime>[0-9]{4}(?:-[0-9]{2}){2}' // date
. 'T[0-9]{2}(?::[0-9]{2}){2}(?:[\+\-][0-9]{2}:[0-9]{2})?)' // time
+ . ' - (?<remoteip>.+)' // remoteip
. ' - (?<identity>.+)' // identity
. ' - (?<type>.+)' // type
. ' - (?<message>.+)' // message
diff --git a/application/views/scripts/log/index.phtml b/application/views/scripts/log/index.phtml
index 79b9239..80140a7 100644
--- a/application/views/scripts/log/index.phtml
+++ b/application/views/scripts/log/index.phtml
@@ -19,6 +19,9 @@
<br>
<?= $this->escape($value->type) ?>
</td>
+ <td style="width: 6em; text-align: center">
+ <?= $this->escape($value->remoteip) ?>
+ </td>
<td style="width: 12em; text-align: center">
<?= $this->escape($value->identity) ?>
</td>
diff --git a/library/Audit/ProvidedHook/AuditLog.php b/library/Audit/ProvidedHook/AuditLog.php
index 39ae592..909c350 100644
--- a/library/Audit/ProvidedHook/AuditLog.php
+++ b/library/Audit/ProvidedHook/AuditLog.php
@@ -14,8 +14,9 @@ public function logMessage($time, $identity, $type, $message, array $data = null
{
$logConfig = Config::module('audit')->getSection('log');
if ($logConfig->type === 'file') {
+ $remoteip = (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) ? $_SERVER['HTTP_X_FORWARDED_FOR'] : $_SERVER['REMOTE_ADDR'];
$file = new File($logConfig->get('path', '/var/log/icingaweb2/audit.log'), 'a');
- $file->fwrite(date('c', $time) . ' - ' . $identity . ' - ' . $type . ' - ' . $message . PHP_EOL);
+ $file->fwrite(date('c', $time) . ' - ' . $remoteip . ' - ' . $identity . ' - ' . $type . ' - ' . $message . PHP_EOL);
$file->fflush();
} elseif ($logConfig->type === 'syslog') {
openlog(
diff --git a/library/Audit/ProvidedHook/AuditStream.php b/library/Audit/ProvidedHook/AuditStream.php
index 869464f..863e93e 100644
--- a/library/Audit/ProvidedHook/AuditStream.php
+++ b/library/Audit/ProvidedHook/AuditStream.php
@@ -16,7 +16,8 @@ public function logMessage($time, $identity, $type, $message, array $data = null
'activity_time' => $time,
'activity' => $type,
'message' => $message,
- 'identity' => $identity
+ 'identity' => $identity,
+ 'remoteip' => $remoteip
];
if (! empty($data)) {
$activityData['data'] = $data;
11 changes: 9 additions & 2 deletions meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ dependencies:

galaxy_info:
role_name: 'icinga2_web'
author: 'Adfinis SyGroup AG'
namespace: adfinis
author: 'Adfinis AG'
description: 'This role installs and configures icingaweb2'
company: 'Adfinis SyGroup AG'
company: 'Adfinis AG'
license: 'GNU General Public License v3'
min_ansible_version: '2.6.0'
platforms:
Expand All @@ -18,3 +19,9 @@ galaxy_info:
- 'icinga2'
- 'monitoring'
- 'icingaweb2'
github_branch: master

collections:
- ansible.posix
- community.general
- robertdebock.roles
s3lph marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 5 additions & 1 deletion tasks/installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
name: '{{ icinga2_web_packages }}'
state: present

- name: install fail2ban using role
ansible.builtin.include_role:
name: robertdebock.roles.fail2ban

# Allow httpd to connect to the mysql database
- name: set httpd_can_network_connect_db flag on and keep it persistent across reboots
seboolean:
Expand Down Expand Up @@ -88,7 +92,7 @@

- name: install modules from github
git: # noqa 401
This conversation was marked as resolved.
Show resolved Hide resolved
repo: 'https://github.com/icinga/icingaweb2-module-{{ item.name }}.git'
repo: '{{ item.url }}'
dest: '/etc/icingaweb2/modules/{{ item.name }}'
version: '{{ item.version }}'
loop: '{{ icinga2_web_modules }}'
Expand Down
7 changes: 7 additions & 0 deletions templates/etc/fail2ban/filter.d/icingaweb2-auth.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Definition]

failregex = ^.*- <HOST> - \S+ - login-failed - User failed to authenticate$

ignoreregex =

datepattern = {^LN-BEG}
Loading