This is a python application that will sync Discord Roles to Authentik Groups.
For this to work you need to:
- Implement the Discord Authentik Identity Provider
- Create a User Property Mapping that stores their Discord ID as an attribute, under
attributes.discord.id - Add a
discord_role_idattribute to each Authentik group you'd like to sync, e.g.discord_role_id: "940183386595655771"NOTE: Make sure to enclose the ID in quotes, otherwise Authentik will round the number & break the link! - Create an Authentik service account, create a role & assign it the following permissions:
Add user to groupRemove user from groupCan view GroupCan view UserCan view User OAuth Source Connection
- Create an API key (under Tokens and App passwords), assigning it to the above service account
- Create a Discord Application (here) & add the bot to your server.
- Make sure it has the Server Members intent, otherwise it won't receive role membership updates
DISCORD_BOT_TOKEN: MZ1yGvKTjE0rY0cV8i47CjAa.uRHQPq.Xb1Mk2nEhe-4iUcrGOuegj57zMC
DISCORD_GUILD_ID: 444746940761243652
AUTHENTIK_HOST: https://authentik-instance/api/v3
AUTHENTIK_API_KEY: I2khOuRBfgZzohV8fQAbJcRXYIJIuXKWe1Q88OTqD8lkOcEoqcwz7z9XIoGJ