Commit Graph

2 Commits (268feaa1f2f5b5f4e2789e97bd0ffbcd9ba9b0b7)

Author SHA1 Message Date
Amir Alexander Abdelbaki 268feaa1f2 feat(ansipa): add Nextcloud, and make FreeIPA the sole identity source
Adds a built-in Nextcloud to the ansipa stack and wires every service's
logins back to FreeIPA, either through Keycloak or directly.

Nextcloud:
  - nextcloud + redis services, sharing the existing postgres server via a
    second database. The initdb hook only fires on an empty data directory,
    so run.sh also creates the role/DB idempotently for stacks that predate
    Nextcloud.
  - served at the /nextcloud subpath of the gateway (OVERWRITEWEBROOT), with
    the /.well-known/* DAV redirects at the server root that sync clients and
    Nextcloud's own setup checks expect.

Identity:
  - keycloak-configure.sh now provisions confidential OIDC clients per relying
    party (nextcloud, proxmox-ve, proxmox-bs, opnsense) plus a realm-wide
    "groups" claim, writing secrets to .oidc-secrets (0600, gitignored).
  - nextcloud-configure.sh binds the IPA LDAP backend as the account source
    and user_oidc for login. The internal username is pinned to the IPA uid
    and unique-uid is disabled, otherwise every SSO login creates a second,
    empty account beside the LDAP one.
  - checkmk-ldap-configure.sh binds CheckMK straight to FreeIPA. CheckMK
    cannot go through Keycloak: SAML is commercial-edition only and no
    edition supports OIDC. The LDAP REST endpoints landed in 2.4 (werk
    #16527) but the stack pins 2.3, so it writes user_connections.mk —
    generated via Python repr() so quotes in a password cannot produce a
    SyntaxError that takes the GUI down, backed up and rolled back if the
    site fails to load it. Directory type is 389directoryserver, which is
    what gives FreeIPA the correct uid/member attribute defaults.

Monitoring:
  - OPNsense local check (gateways, pf state table vs its hard limit,
    firmware, CARP) plus an installer. POSIX sh, since OPNsense is FreeBSD
    with no bash or GNU grep. Transport is agent-over-SSH rather than inetd
    on 6556, because OPNsense regenerates inetd.conf/services/hosts.allow
    from config.xml and silently reverts those edits on reboot.

Fixes found along the way:
  - keycloak-configure.sh used KC_URL without the /auth relative path and
    probed /health/ready, which lives on management port 9000 and is not
    under that path — so it 404'd and timed out on this deployment.
  - .env.example had an unquoted `cn=Directory Manager`, which the shell
    scripts sourcing it parsed as a command named `Manager`.
  - summary heredocs printed raw escape codes; colours now use ANSI-C quoting.

docs/md/ansipa-sso.md covers the identity chain, the per-service support
matrix, Proxmox VE/PBS OpenID realm setup, and why packet captures should
not be tunnelled through the CheckMK API.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BWLuyyrydC1u2FjM7naPcz
2026-08-10 14:51:27 +02:00
Amir Alexander Abdelbaki 6bb19cea78 feat(ansipa): integrate CheckMK CE monitoring
Adds full CheckMK CE 2.3 monitoring integration to the ansipa policy
enforcement system. Monitoring is group-driven — adding a host to an
IPA hostgroup installs the relevant agent checks automatically.

New monitoring groups:
  dev_mon_base      — install check-mk-agent, register host in CMK;
                      packages check + built-in CPU/RAM/disk/uptime
  dev_mon_malware   — ClamAV scan results from dev_security-scan log
  dev_mon_timeshift — Timeshift snapshot age (WARN >5d, CRIT >10d)
  dev_mon_power     — CPU package TDP via Intel RAPL or lm-sensors
  usr_mon_logins    — SSH login attempts (success/failed/invalid-user)

Key implementation details:
- ansipa-checkmk-setup.sh: one-time folder/group creation on FreeIPA
  container; reads automation secret from shared cmk-creds volume;
  stores credentials in IPA dev_mon_base description for clients
- ansipa-checkmk.service: starts after IPA first-boot, retries until
  both IPA and CheckMK are ready
- docker-compose.yml: CheckMK container adds port 8000 (agent receiver
  for push mode); command override writes automation.secret to shared
  volume, patches cookie_auth.conf for API access, and polls
  /cmk-creds/push-mode-*.req to configure push-agent hosts in hosts.mk
- ansipa-enforce-policies.sh: local check scripts for all 5 groups;
  cmk-agent-ctl registration + auto push timer when push mode is active
- CheckMK REST API path corrected to /cmk/check_mk/api/1.0/ (not
  /cmk/api/1.0/ which returns 404 in 2.3)
- .gitignore added to prevent accidental commit of .env test creds

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DHops6PU4c2Mv5UyhUj8Ms
2026-07-01 18:32:28 +02:00