Zéro-confiance : Keycloak→PG en verify-full + root_ca lisible (0644)

- client_pki : root_ca.crt en 0644 (un cert racine est PUBLIC ; requis pour
  que les clients TLS non-root — keycloak, forgejo… — puissent vérifier).
- serveur_keycloak : db-url-properties sslmode=verify-full + sslrootcert.

Incident maîtrisé : 1er essai, keycloak (user keycloak) ne pouvait pas lire
root_ca 0600 → SSO down → restauré en <1 min → corrigé (0644) → verify-full OK.
Prouvé : realm 200, sslmode=verify-full, aucune erreur SSL/DB.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Daniel Allaire 2026-07-04 18:45:16 -04:00
parent 5aa7fcafdb
commit fa6ef8b031
3 changed files with 13 additions and 0 deletions

View file

@ -66,6 +66,11 @@
environment:
STEPPATH: "{{ client_pki_steppath }}"
- name: Rendre le certificat racine lisible par tous (cert public, requis par les clients TLS)
ansible.builtin.file:
path: "{{ client_pki_steppath }}/certs/root_ca.crt"
mode: "0644"
- name: Obtenir le certificat d'hote
ansible.builtin.command:
cmd: >-

View file

@ -58,3 +58,8 @@ serveur_keycloak_role_mapper_clients: []
# Assignations rôle→utilisateur (ex. [{user: testmail, role: grafana-editor}]).
# En prod, préférer l'assignation via groupe d'annuaire ; ici, explicite pour la preuve.
serveur_keycloak_role_assignments: []
# TLS vers PostgreSQL (zero-confiance). Vide = pas de verif (compat). 'verify-full' =
# chiffre + verifie le cert serveur contre le root_ca step-ca (l'hote doit etre dans le SAN).
serveur_keycloak_db_sslmode: ""
serveur_keycloak_db_sslrootcert: "/etc/step/certs/root_ca.crt"

View file

@ -2,6 +2,9 @@
db=postgres
db-url-host={{ serveur_keycloak_db_host }}
db-url-database={{ serveur_keycloak_entree.base }}
{% if serveur_keycloak_db_sslmode | default('') %}
db-url-properties=?sslmode={{ serveur_keycloak_db_sslmode }}&sslrootcert={{ serveur_keycloak_db_sslrootcert }}
{% endif %}
db-username={{ serveur_keycloak_entree.proprietaire }}
# Derriere serveur_nginx (TLS termine a l'edge).