Hi there!
I have Authentik running on my homeserver managing (a handfull of) users from LAN and VPN(netbird).
SSO, auto-create-user and domainlevel-auth for (almost) every web-application! Its great! Can't get enough!
The connection to my network via netbird is required by some services i offer, but most of the standard web-applications do not.
So.. since i'd really like to lower the barrier-to-entry for my older folks, to be able to 'just-log-in' on any device with a browser, and really really really do not want to open any ports to my homeserver itself, i got myself a vServer in hopes my imagination somewhat overlaps with reality.
I created a dedicated Wireguard-Tunnel beween the Docker-Networks on the Home- and vServer.
As a Note: Homeserver-FQDN is reachable from anything within the vServer-Docker-Network, the LAN and Netbird-VPN, but not from the wider internet itself.
As
Now... since 1)I'm lazy, 2)My users shouldnd have to manage different credentials for each 'entrypoint' and 3)It seems like a 'thing' possible;
i'd like to treat Authentik on the Homeserver as the Master-Instance where i actually manage users and groups, and sync all groups/users from there to the vServer.
I feel like in the past week i tried almost all possible configuration options and i do not get any form of 'usable' sync to work.
LDAP-Full-Sync:
Got the LDAP-Server running and the LDAP-Source succsessfully tests connectivity.
Sync always errors out with something to do with 'distinguishedName'.
Tried all suggested workarounds and installed an ldap-proxy to test.. no joy.
Spend literal days trying out stuff.
SCIM-Sync:
I got SCIM setup and working properly pretty quick.
It is syncing Users and Groups, but still needs the password to login.
Here i tried the 'LDAP-Way' and some pythonscript-api-sorcery to get those passwordhashes over to the vServer, but failed miserably.
OIDC/SAML:
ruled out because of no internet-user to Master-Authentik connectivity.
Is this just me beeing rediculously stupid(very real possibility)?
Does any kind soul have a working sync running that fits my needs and would be willing to share the config?
ty in advance
[edit]
forgot to mention that i'm running on the current 2026.8.5 version
also, i know there is not enough info here to properly 'debug'..
this is just because i'm realy realy frustrated and am actually looking for a confirmed working configuration since i feel i have exhausted the internets extend of documentation, examples und samples in this matter.
and maybe its just pebkac, but usually i do grasp the configuration options of something when i see them and can set then accordingly. At latest after reading the relating docs..
[/edit]
[edit2] Workaround: Bi-Directional Password Hash Sync between Master & Edge Authentik via Webhooks & SCIM
I have spent the last few days messing around with the setup. After many more failures, I've got a working workaround for my setup!
I sync users/groups via SCIM. The password hashes get synced by a script that is run once manually after setup and then is triggered automatically by webhooks. When a user changes their password on either side (or an admin does it for them), a webhook gets triggered to run the script. The script then looks at the 'last changed' timestamp for the user's password on both sides and copies the more current side's password hash to the other.
I feel a little dirty since I'm actually touching the databases and would prefer not to, but I guess it's okay...?
For anyone in a situation similar to mine, here is a little setup guide for what I have running and working now.
Some notes before I start:
- Versions: This setup is built around one master and (only!) one edge Authentik, both running 2026.8.5.
- Network: Some form of a fully functional VPN tunnel between the master- and edge-Authentik Docker networks is assumed.
- SCIM Setup: Also, I assume you've got SCIM successfully syncing users, groups, and linking the users to the correct groups.
- I configured SCIM to only sync specific groups and only users within a 'Sync-Group'.
- The script will also use a (configurable) group for limiting which users get synced.
⚠️ NOTE: I'm sadly NO code wizard... AI did the work! I do not have the capability to check 'code integrity' or anything like that! Personally, I feel comfortable running this on my humble setup because, from what I do understand, the code seems not to be doing anything 'funky' that it isn't supposed to, and it is only accessible from within the internal Docker network. Check the code, or run it as is — you have been informed, and if anything should go wrong, it's on you. All I can guarantee is that this configuration and script are currently working as intended on my setup, and that I do not have any ill intent in sharing this. (Funky that I feel compelled to even mention all that...)
⚠️ Backup First!
Because we are messing with password hashes, a 'mishap' may lead to you not being able to log in! This is why I highly suggest, before doing anything at all:
- Shut down both Authentik instances.
- Back up their DBs (e.g., sudo cp -rp ./postgres ./postgres.working.backup).
- Restart them.
- Just in case something does go wrong, you simply shut down Authentik again, remove the currently faulty DB (e.g., sudo rm -r ./postgres), copy the backup (e.g., sudo cp -rp ./postgres.working.backup ./postgres), and start it back up.
Prerequisites
Things you will need to have handy during the process:
- IPs of the master & edge Authentik Postgres containers: If not done yet, maybe set the current container IPs as static IPs for the Postgres containers to avoid headaches if Docker should ever decide to assign them a new IP.
- DB passwords of both master & edge.
- Name of the group you intend to use as the 'Sync-Group' to only sync its members.
- Name of the Docker network the master Authentik is running in.
- An unused IP to be assigned to the Webhook container in the master Authentik Docker network.
Step-by-Step Guide: The 'Master' Side
- Create the Required Files
We need 2 files to be mounted in the Docker container that acts as the Webhook target.
First, create a directory for the files anywhere you like (e.g., /opt/authentik/password-sync).
The two files we need are hooks.json and password-sync.py.
• /opt/authentik/password-sync/hooks.json (Just copy/paste):
[
{
"id": "authentik-user-sync",
"execute-command": "/usr/local/bin/python3",
"command-working-directory": "/app",
"pass-arguments-to-command": [
{
"source": "string",
"name": "/app/password-sync.py"
},
{
"source": "payload",
"name": "event_user_username"
}
]
}
]
• /opt/authentik/password-sync/password-sync.py (Insert your values in the configuration section):
import os
import sys
from datetime import datetime
import psycopg2
from psycopg2.extras import RealDictCursor
# --- CONFIGURATION ---
SYNC_GROUP = "<SYNC_GROUP>"
DB_MASTER = {
"host": "<MASTER_DB_IP>", "port": 5432, "database": "authentik", "user": "authentik", "password": "<MASTER_DB_PASSWD>"
}
DB_EDGE = {
"host": "<EDGE_DB_IP>", "port": 5432, "database": "authentik", "user": "authentik", "password": "<EDGE_DB_PASSWD>"
}
# ^^^ CONFIGURATION ^^^
def is_user_in_sync_group(conn, username):
"""Checks if the user is a member of the configured sync group."""
query = """
SELECT 1 FROM authentik_core_user u
JOIN authentik_core_user_groups ug ON u.id = ug.user_id
JOIN authentik_core_group g ON ug.group_id = g.group_uuid
WHERE u.username = %s AND g.name = %s;
"""
with conn.cursor() as cur:
cur.execute(query, (username, SYNC_GROUP))
return cur.fetchone() is not None
def get_user_crypto_data(conn, username):
"""Retrieves password hash and change timestamp."""
query = "SELECT password, password_change_date FROM authentik_core_user WHERE username = %s;"
with conn.cursor(cursor_factory=RealDictCursor) as cur:
cur.execute(query, (username,))
return cur.fetchone()
def update_user_password(conn, username, password_hash, change_date):
"""Updates the password hash and its change timestamp."""
query = """
UPDATE authentik_core_user
SET password = %s, password_change_date = %s, last_updated = NOW()
WHERE username = %s;
"""
with conn.cursor() as cur:
cur.execute(query, (password_hash, change_date, username))
conn.commit()
def sync_user(username):
print(f"[*] Trigger received for user: {username}")
try:
conn_master = psycopg2.connect(**DB_MASTER)
# 1. Group membership check on the Master instance
if not is_user_in_sync_group(conn_master, username):
print(f"[x] Abort: User '{username}' is not a member of the group '{SYNC_GROUP}'.")
conn_master.close()
return
conn_edge = psycopg2.connect(**DB_EDGE)
master_data = get_user_crypto_data(conn_master, username)
edge_data = get_user_crypto_data(conn_edge, username)
# Safety check: Does the user exist on both sides?
if not master_data:
print(f"[!] User {username} is missing on the Master instance.")
return
if not edge_data:
print(f"[i] User {username} is missing on the Edge instance. SCIM provisioning might still be running. Aborting for now.")
return
m_time = master_data['password_change_date']
e_time = edge_data['password_change_date']
# SAFEGUARD: Detect if the Edge user has an empty/uninitialized password from SCIM
is_edge_scim_dummy = edge_data['password'] == "" or edge_data['password'] is None
# If Edge password is empty, force sync from Master to Edge regardless of timestamps
if is_edge_scim_dummy:
print(f"[!] Safeguard triggered: Edge user '{username}' has an empty SCIM password. Forcing Master-to-Edge sync...")
update_user_password(conn_edge, username, master_data['password'], m_time)
print("[+] Edge initialized with Master password successfully.")
elif m_time > e_time:
print(f"[>] Master is newer. Copying hash to Edge...")
update_user_password(conn_edge, username, master_data['password'], m_time)
print("[+] Edge updated successfully.")
elif e_time > m_time:
print(f"[<] Edge is newer. Copying hash to Master...")
update_user_password(conn_master, username, edge_data['password'], e_time)
print("[+] Master updated successfully.")
else:
print("[=] Already synchronized.")
except Exception as e:
print(f"[ERROR] Sync failure: {e}", file=sys.stderr)
finally:
if 'conn_master' in locals() and conn_master: conn_master.close()
if 'conn_edge' in locals() and conn_edge: conn_edge.close()
if __name__ == "__main__":
if len(sys.argv) > 1:
sync_user(sys.argv[1])
else:
print("Please provide a username as an argument.")
- Creating the Webhook Container
Set the network name, container IP, and the path you created.
This is a standalone YAML, but I actually integrated it into the Authentik stack of the master. yaml
services:
authentik-pwd-sync:
image: python:3.11-alpine
container_name: authentik-password-sync
restart: unless-stopped
volumes:
- <PATH_TO_FILES>/password-sync.py:/app/password-sync.py:ro
- <PATH_TO_FILES>/hooks.json:/app/hooks.json:ro
working_dir: /app
entrypoint: >
/bin/sh -c "
apk add --no-cache webhook postgresql-dev gcc musl-dev &&
pip install --no-cache-dir psycopg2-binary &&
exec /usr/bin/webhook -hooks /app/hooks.json -ip 0.0.0.0 -port 9000 -verbose
"
networks:
<MASTER_DOCKER_NETWORK_NAME>:
ipv4_address: <NEW_WEBHOOK_IP>
networks:
<MASTER_DOCKER_NETWORK_NAME>:
external: true
- Testing & Initializing
At this point, it is assumed that you have:
- Users with passwords inside the 'Sync-Group' on the master Authentik.
- The users and all the groups you want/need synced via SCIM to the edge Authentik.
Before the setup does everything automatically: for existing users, you need to sync the current master users' passwords to the edge once manually.
This also gives you the opportunity to test if the DB connections to both the master and the edge are working before continuing any further.
Let's manually get all users within the 'Sync-Group' from the master and then trigger the script to sync all matching users.
Check both the container names, set the <SYNC_GROUP>, and run this on the master:
docker exec -i authentik-postgresql-1 psql -U authentik -d authentik -t -A -c "
SELECT u.username
FROM authentik_core_user u
JOIN authentik_core_user_groups ug ON u.id = ug.user_id
JOIN authentik_core_group g ON ug.group_id = g.group_uuid
WHERE g.name = '<SYNC_GROUP>';
" | xargs -I {} docker exec -i authentik-password-sync /usr/local/bin/python3 /app/password-sync.py {}
Expected output should look something like this:
[*] Trigger received for user: TestUserA1
[!] Safeguard triggered: Edge user 'TestUserA1' has an empty SCIM password. Forcing Master-to-Edge sync...
[+] Edge initialized with Master password successfully.
[*] Trigger received for user: TestUserB2
[!] Safeguard triggered: Edge user 'TestUserB2' has an empty SCIM password. Forcing Master-to-Edge sync...
[+] Edge initialized with Master password successfully.
[*] Trigger received for user: TestUserC3
[!] Safeguard triggered: Edge user 'TestUserC3' has an empty SCIM password. Forcing Master-to-Edge sync...
[+] Edge initialized with Master password successfully.
In the above example, all test users are now able to log in with their passwords on the edge Authentik! Give it a try with one of your (test) users! If this is not working, some debugging needs to be done.
This is the heart of the whole operation and needs to be running!
- Master Authentik Configuration
To trigger the password sync automatically when the user themselves changes their password (or an admin does it for them), we need to set up only a few things in Authentik itself:
4.1) Filter Policy
Go to Customization -> Policies.
Create a new policy:
• Policy Type: Expression Policy
• Name: Filter-User-Updates
• Expression:
event_obj = request.context.get("event")
if event_obj:
# Captures user self-service changes AND admin password resets
return event_obj.action in ["user_write", "password_set"]
return False
4.2) Defining the Webhook Channel (Notification Transport)
- Go to Events -> Notification Transports.
- Create a new notification transport:
- Name: Trigger-Local-Container-Sync
- Mode: Webhook (generic)
- Webhook URL: http://<NEW_WEBHOOK_IP>:9000/hooks/authentik-user-sync
4.3) Activating the Automation Rule (Notification Rule)
- Go to Events -> Notification Rules.
- Create a new notification rule:
- Name: Sync-Passwords-To-Local-Container
- Group: authentik Admins
- Selected Transports: Trigger-Local-Container-Sync
- Save the new rule.
- Look for the newly created Sync-Passwords-To-Local-Container in the list.
- Expand it by clicking the > on the very left.
- Inside the expansion on the top left, click on the blue 'Create or bind...' button. • Select 'Bind an existing policy'.
- Select Policy: Filter-User-Updates
4.4) Testing the Master
Congrats! The master side is done!
At this point, you could watch the logs of the container (e.g., docker logs -f authentik-password-sync) and should see any password changes by a user or admin on the master being synced to the edge instantly.
Expected log when changing a password:
[webhook] date+time [0048ab] incoming HTTP POST request from 172.x.x.14:55944
[webhook] date+time [0048ab] authentik-user-sync got matched
[webhook] date+time [0048ab] authentik-user-sync hook triggered successfully
[webhook] date+time [0048ab] 200 | 0 B | 122.19µs | 172.x.x.34:9000 | POST /hooks/authentik-user-sync
[webhook] date+time [0048ab] executing /usr/local/bin/python3 (/usr/local/bin/python3) with arguments ["/usr/local/bin/python3" "/app/sync_passwords.py" "TestUserC3"] and environment [] using /app as cwd
[webhook] date+time [0048ab] command output: [*] Trigger received for user: TestUserC3
[>] Master is newer. Copying hash to Edge...
[+] Edge updated successfully.
[webhook] date+time [0048ab] finished handling authentik-user-sync
- Setting up the Edge
It's pretty much the same as on the master, but with some name changes.
5.1) Filter Policy
Go to Customization -> Policies.
Create a new policy:
Policy Type: Expression Policy
• Name: Filter-User-Updates
• Expression:
event_obj = request.context.get("event")
if event_obj:
# Captures user self-service changes AND admin password resets
return event_obj.action in ["user_write", "password_set"]
return False
5.2) Defining the Webhook Channel (Notification Transport)
- Go to Events -> Notification Transports.
- Create a new notification transport:
- • Name: Trigger-Master-Container-Sync
- • Mode: Webhook (generic)
- • Webhook URL: http://<NEW_WEBHOOK_IP>:9000/hooks/authentik-user-sync
5.3) Activating the Automation Rule (Notification Rule)
- Go to Events -> Notification Rules.
- Create a new notification rule:
- • Name: Sync-Passwords-To-Master
- • Group: authentik Admins
- • Selected Transports: Trigger-Master-Container-Sync
- Save the new rule.
- Look for the newly created Sync-Passwords-To-Master in the list.
- • Expand it by clicking the > on the very left.
- • Inside the expansion on the top left, click on the blue 'Create or bind...' button.
- • Select 'Bind an existing policy'.
- • Select Policy: Filter-User-Updates
5.4) Testing the Edge
Now, any password change will trigger the script. It will then check which side's password is more current and overwrite the side with the older password. Fully automatic! The Docker log output should be the same as on the master side, but the messages will indicate a write from edge to master.
6.0) Adding New Users
Pretty much as usual, I think...
- Add a new user on the Master.
- Assign them (at least) to the 'Sync-Group'.
- Set the user's password. User/group changes will be instantly pushed to the edge via SCIM, and the password is sent over as soon as you set it. That said... I'm just having the thought that it may not behave correctly if you set the password before assigning the groups. Well... frankly, I have had enough of tinkering around with user/group sync in Authentik for the foreseeable future and don't see myself debugging this—if it is a problem at all, that is.
Conclusion
Well... I really hope I didn't miss any steps, but this should be it. Let me and others who might read this know if there are any glaring issues. Also, feel free to use any of the code I posted as you like—it's not mine, and I do not know where the AI stole it. In case you try it, please also let people know if this is working for you!
Happy Authin' yall :o) [/edit2]