Caddy Discord (Authentication Provider)

I’ve created a module with the goal of tightly integrating authentication for Discord based identities.

Download binary via GitHub releases, or build with

xcaddy build --with

With v1.0.0 it is possible to authenticate routes based on either (or combination of):

  • User ID
  • Guild Membership (ie. User is in Server)
  • Role ID (ie. User has specific role in Guild)

Discord OAuth App is required (no bot is required).

I’m using this in production for a gaming community and it’s been smooth sailing but given it is a version 1.0.0 release and has only been tested by me, I wouldn’t recommend it for high throughput just yet.

Example Usage

    discord {
        client_id 1000000000000000000 # Discord app OAuth client ID 
        client_secret 8CEPZZZZZAfl_w19ZZZZW_k # Discord app OAuth secret
        redirect http://localhost:8080/discord/callback # Route you've configured with `discordauth callback`

        realm clique {
            guild 106307051119907 {
                role 10630111112755034

http://localhost:8080 {
    route /discord/callback {
         # Desigate route as OAuth callback endpoint
         discord callback 

    route /discordians-only {
         # Only allow discord users that auth against 'clique' realm 
         protect using clique 
         respond "Hello {http.auth.user.username}!<br /><br /><img src='{}/{http.auth.user.avatar}?size=4096.png'> "

    respond "Hello, world!"


That would require checking out the repo. I think you meant to remove the =./ there.

1 Like