feat(cockpit): allow 2FA auth

Fixes #60

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-12-14 20:53:24 +01:00
parent f5335e0f0c
commit 7d8d187e97
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8
4 changed files with 27 additions and 0 deletions

View file

@ -1,5 +1,8 @@
certbot_email: "{{ vault_certbot_email }}"
cockpit_2fa: true
cockpit_has_reverse_proxy: true
host_fqdn: "{{ vault_host_fqdn }}"
porkbun_apikey: "{{ vault_porkbun_apikey }}"

View file

@ -3,3 +3,9 @@
# reverse proxy (adjusts the origin, so that the Cockpit doesn't drop sessions,
# and checks for SSL/TLS connections)
cockpit_has_reverse_proxy: false
# Boolean variable that denotes whether to install dependencies for 2FA auth
# to Cockpit (Google Authenticator and QR encoding utilities for enrolling the
# OTP), also installs the rule to the pam.d so that the 2FA is required for
# logging in to the Cockpit.
cockpit_2fa: false

View file

@ -3,3 +3,11 @@
ansible.builtin.package:
name: cockpit
state: present
- name: Install deps for 2FA in Cockpit
ansible.builtin.package:
name:
- google-authenticator
- qrencode-libs
state: present
when: cockpit_2fa

View file

@ -12,6 +12,16 @@
group: root
when: cockpit_has_reverse_proxy
- name: Require 2FA for logging into the Cockpit
ansible.builtin.lineinfile:
line: auth required pam_google_authenticator.so nullok
path: /etc/pam.d/cockpit
create: true
mode: 0644
owner: root
group: root
when: cockpit_2fa
- name: Enable cockpit
ansible.builtin.service:
name: "cockpit.socket"