![]() |
This is a machine translation based on the English version of the article. It might or might not have already been subject to text preparation. If you find errors, please file a GitHub issue that states the paragraph that has to be improved. |
1. Introduzione
Il single sign-on (autenticazione unica) alla GUI di Checkmk con Kerberos non è ufficialmente supportato da Checkmk, ma puoi facilmente configurarlo da solo. Queste istruzioni ti mostreranno come farlo.
I seguenti prerequisiti devono essere soddisfatti prima che la configurazione di Checkmk possa essere modificata retroattivamente in SSO (autenticazione unica) con Kerberos:
La versione di Apache è 2.4 o più recente.
Sul server Checkmk è installato il modulo
libapache-mod-auth-kerb
(omod_auth_kerb
su Red Hat Enterprise Linux e CentOS oapache2-mod_auth_kerb
su SUSE).Il client Kerberos è installato e configurato sul server Checkmk.
È stata installata una Keytab - ad es.
/etc/krb5.keytab
- che può essere letta dall'utente dell'istanza.Il server Checkmk è stato configurato come Service Principal.
Il browser del cliente è stato configurato per l'accesso tramite Kerberos.
Opzionale:
Se vuoi che gli utenti senza SSO possano comunque loggarsi tramite la normale pagina di login, è necessario abilitare l'autenticazione tramite cookie.
2. Integrazione di Kerberos
Per switchare Checkmk all'autenticazione tramite Kerberos, cancella il file ~/etc/apache/conf.d/auth.conf
e riscrivilo. Le voci all'inizio del contenuto del seguente file sono solo esempi. Pertanto, modifica tutte le righe che iniziano con l'espressione Define
per adattarle al tuo ambiente:
Define SITE MyCheckmkSite
Define REALM MyRealm.org
Define SERVICENAME myservice.mydomain.tld
Define KEYTAB /omd/sites/${SITE}/etc/apache/cmk_http.keytab
<IfModule !mod_auth_kerb.c>
LoadModule auth_kerb_module /usr/lib/apache2/modules/mod_auth_kerb.so
</IfModule>
<Location /${SITE}>
<If "! %{HTTP_COOKIE} =~ /^(.*;)?auth_${SITE}/ && \
! %{REQUEST_URI} = '/${SITE}/check_mk/register_agent.py' && \
! %{REQUEST_URI} = '/${SITE}/check_mk/deploy_agent.py' && \
! %{REQUEST_URI} = '/${SITE}/check_mk/run_cron.py' && \
! %{REQUEST_URI} = '/${SITE}/check_mk/restapi.py' && \
! %{REQUEST_URI} = '/${SITE}/check_mk/webapi.py' && \
! %{REQUEST_URI} = '/${SITE}/check_mk/automation.py' && \
! %{REQUEST_URI} -strmatch '/${SITE}/check_mk/api/*' && \
! %{REQUEST_URI} = '/${SITE}check_mk/ajax_graph_images.py' && \
! %{QUERY_STRING} =~ /(_secret=|auth_|register_agent)/ && \
! %{REQUEST_URI} =~ m#^/${SITE}/(omd/|check_mk/((images|themes)/.*\.(png|svg)|login\.py|.*\.(css|js)))# ">
Order allow,deny
Allow from all
Require valid-user
AuthType Kerberos
AuthName "Checkmk Kerberos Login"
KrbMethodNegotiate on
KrbMethodK5Passwd off
KrbLocalUserMapping on
# Environment specific: Path to the Keytab, Realm and ServicePrincipal
KrbAuthRealm ${REALM}
KrbServiceName HTTP/${SERVICENAME}@${REALM}
Krb5Keytab ${KEYTAB}
# When Kerberos auth fails, show the login page to the user
ErrorDocument 401 '<html> \
<head> \
<meta http-equiv="refresh" content="1; URL=/${SITE}/check_mk/login.py"> \
</head> \
<body> \
Kerberos authentication failed, redirecting to login page. \
<a href="/${SITE}/check_mk/login.py">Click here</a>. \
</body> \
</html>'
</If>
</Location>
# These files are accessible unauthenticated (login page and needed ressources)
<LocationMatch /${SITE}/(omd/|check_mk/(images/.*\.png|login\.py|.*\.(css|js)))>
Order allow,deny
Allow from all
Satisfy any
</LocationMatch>
Una volta eseguita la configurazione di esempio mostrata, saranno consentite solo le autenticazioni tramite Kerberos. Ora devi decidere se continuare a supportare basic auth
con o senza cookie - per gli utenti che non hanno SSO o come ripiego. Ciò che dovrai configurare a questo scopo è spiegato nei due capitoli seguenti.
3. Consenti l'autenticazione di base
Se vuoi continuare a consentire l'autenticazione tramite basic auth
oltre all'SSO tramite Kerberos, devi modificare una riga della configurazione precedente.
Per farlo, cambia il valore della riga seguente in on
:
KrbMethodK5Passwd on
4. Verifica l'autenticazione tramite cookie
Per rendere più comoda l'autenticazione, Checkmk supporta anche il log in tramite cookie. In un'istanza Checkmk nuova e non modificata, questa è attualmente l'opzione predefinita.
Infine, ma non meno importante, devi verificare se questa opzione di autenticazione è ancora abilitata e se deve rimanere tale.
Puoi verificare lo stato attuale del tuo sito con il seguente comando:
OMD[mysite]:~$ omd config show MULTISITE_COOKIE_AUTH
Se ricevi il valore on
e vuoi mantenere l'autenticazione tramite cookie abilitata, ad esempio come ripiego, a questo punto non devi fare altro.
Se invece vuoi disabilitare MULTISITE_COOKIE_AUTH
, puoi farlo con il seguente comando:
OMD[mysite]:~$ omd config set MULTISITE_COOKIE_AUTH off
Quindi cancella il file cookie_auth.conf
dalla directory Apache del sito:
OMD[mysite]:~$ rm ~/etc/apache/conf.d/cookie_auth.conf
5. Diagnostica
Puoi verificare con i seguenti comandi se la configurazione di Kerberos funziona:
root@linux# kinit -p username
root@linux# klist