Simple Auto Login for Webtrees
This module provides a simple way to add a SSO auto login for webtrees in combination with a authentication proxy (like oauth2-proxy).
Installation
Requires webtrees 2.0.
Using Git
If you are using git
, you could also clone the current main branch directly into your modules_v4
directory
by calling:
git clone https://github.com/fanningert/webtrees_simpleautologin.git modules_v4/webtrees_simpleautologin
Manual installation
To manually install the module, perform the following steps:
- Download the latest release.
- Upload the downloaded file to your web server.
- Unzip the package into your
modules_v4
directory. - Rename the folder to
webtrees_simpleautologin
Enable
- Visit the Control Panel
- Click "All modules"
- Scroll to "Simple Auto Login"
- Check the checkbox for this module.
- Scroll to the bottom.
- Click the "save" button.
- Add
trusted_header_authenticated_user
to theconfig.ini.php
of webtrees
Known server parameter:
- oauth2-proxy: HTTP_X_FORWARDED_PREFERRED_USERNAME
- Apache mod_ssl: SSL_CLIENT_S_DN_CN
- general: REMOTE_USER
Example: trusted_header_authenticated_user="REMOTE_USER";
Disable
- Visit the Control Panel
- Click "All modules"
- Scroll to "Simple Auto Login"
- Clear the checkbox for this module.
- Scroll to the bottom.
- Click the "save" button.
Alternatively, you can unload the module by renaming modules_v4/webtrees_simpleautologin/
to modules_v4/webtrees_simpleautologin.disable/
Uninstall
It is safe to delete the webtrees_simpleautologin
directory at any time.
Landscape examples
oauth2-proxy
In my installation, I have Caddy as a first line reverse proxy. Behind this is a authentication proxy (oauth2-proxy) for the oauth authentication with keycloak.
caddy -> oauth2-proxy -> webtrees
|
v
Keycloak
caddy configuration
webtrees.example.com {
reverse_proxy <oauth-proxy: https://x.x.x.x:port> {
transport http {
tls_insecure_skip_verify
}
}
}
oauth2-proxy configuration
I am running oauth2-proxy as container (podman).
podman create --name "oauthproxy_core" --pod "oauthproxy" \
-v "/etc/localtime:/etc/localtime:ro" \
quay.io/oauth2-proxy/oauth2-proxy \
--provider=oidc \
--provider-display-name="Keycloak" \
--client-id="app_webtrees" \
--client-secret="<client-secret>" \
--email-domain=* \
--oidc-issuer-url="http(s)://<keycloak host>/auth/realms/<realm>" \
--login-url="http(s)://<keycloak host>/auth/realms/<realm>/protocol/openid-connect/auth" \
--redeem-url="http(s)://<keycloak host>/auth/realms/<realm>/protocol/openid-connect/token" \
--validate-url="http(s)://<keycloak host>/auth/realms/<realm>/protocol/openid-connect/userinfo" \
--allowed-group="<allowed_user_group>" \
--whitelist-domain="<.example.com>" \
--cookie-domain="<webtrees.example.com>" \
--cookie-secure=true \
--cookie-secret="${COOKIE_SECRET}" \
--scope="openid profile email roles" \
--http-address="127.0.0.1:4180" \
--upstream="<webtrees url>" \
--ssl-upstream-insecure-skip-verify="true" \
--reverse-proxy="true" \
--insecure-oidc-allow-unverified-email=true \
--skip-provider-button=true
More information can be find here.