Skip to content

breakfix: unrecognized directive: oauth #434

@nathangemmill

Description

@nathangemmill

Describe the issue

I've deployed Caddy and Caddy Security with docker. I can see the security module has been loaded when I run "caddy list-modules" but I have configured Microsoft OAauth and entered in my settings, but continue to get an error when trying to validate the Caddyfile.

Error: adapting config using caddyfile: /etc/caddy/Caddyfile_new:3: unrecognized directive: oauth

Configuration

Paste full Caddyfile below:

security {
    oauth identity provider azure {
        realm azure
        driver azure
        tenant_id {env.ENTRA_TENANT_ID}
        client_id {env.ENTRA_CLIENT_ID}
        client_secret {env.ENTRA_CLIENT_SECRET}
        scopes openid email profile
    }

    authentication portal myportal {
        enable identity provider azure
        backend oauth {
            provider azure
        }

        cookie domain bingo.com.au

        crypto default token lifetime 86400

        ui {
            links {
                "My Token" "/whoami" icon "las la-user"
            }
        }

        transform user {
            match origin azure
            action add role prefix/user
        }
    }

    authorization policy defaultpolicy {
        set auth url https://auth.bingo.com.au/
        allow roles prefix/user
    }

    # If you want another policy that references a different portal/provider
    authorization policy otherpolicy {
        set auth url https://auth.bingo.com.au/oauth2/azure
        allow roles entrarole
    }
}

uptime.bingo.com.au {
        reverse_proxy uptime-kuma:3001
        tls {
                dns cloudflare {env.CF_API_TOKEN}
        }
}

bingo.com.au {
        root * /srv/bingo-com-au
        encode gzip
        file_server

        tls {
                dns cloudflare {env.CF_API_TOKEN}
        }

Version Information

Provide output of caddy list-modules --versions | grep -E "(auth|security)" below:

http.authentication.hashes.bcrypt v2.10.2
http.authentication.providers.http_basic v2.10.2
http.handlers.authentication v2.10.2
tls.client_auth.verifier.leaf v2.10.2
http.authentication.providers.authorizer v1.1.31
http.handlers.authenticator v1.1.31
security v1.1.31

Expected behavior

Validate and format the caddyfile without errors

Additional context

Below is my Dockerfile I use to build the image with the modules installed.

FROM caddy:2-builder AS builder

RUN xcaddy build \
--with github.com/caddy-dns/cloudflare \
--with github.com/greenpau/caddy-security

FROM caddy:2
COPY --from=builder /usr/bin/caddy /usr/bin/caddy

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions