traefik-oidc-auth: Error with redirect uri after initial setup

I am using version 0.3.2 and have created a new project in Zitadel with the following settings:

  • Type: Web
  • Auth Method: Code
  • Redirect URIs: https://zitadel.myowndomain.com/oauth2/callback

Here is my Traefik configuration:

# traefik.yml
api:
  dashboard: true

metrics:
  prometheus:
    addRoutersLabels: true

certificatesResolvers:
  http_resolver:
    acme:
      email: "auth@myowndomain.com"
      storage: "/etc/traefik/acme_letsencrypt.json"
      caServer: "https://acme-v02.api.letsencrypt.org/directory"
      dnsChallenge:
        provider: cloudflare
        resolvers:
          - "1.1.1.1:53"
          - "1.0.0.1:53"

entryPoints:
  ping:
    address: ':88'
  web:
    address: ':80'
    http:
      redirections:
        entryPoint:
          to: websecure
          scheme: https
  websecure:
    address: ':443'
    http:
      middlewares:
        - default@file
        - traefik-bouncer@file

ping:
  entryPoint: "ping"

global:
  checknewversion: true
  sendanonymoususage: false

providers:
  docker:
    endpoint: "tcp://socket-proxy:2375"
    exposedByDefault: false
    network: "proxy"
  file:
    directory: "/etc/traefik/dynamic_conf"
    watch: true

log:
  level: INFO
  filePath: "/var/log/traefik/traefik.log"
  format: json
  maxSize: 10
  maxBackups: 10
  maxAge: 14

accessLog:
  filePath: "/var/log/traefik/access.log"
  format: json
  bufferingSize: 50
  fields:
    defaultMode: keep

experimental:
  plugins:
    traefik-oidc-auth:
      moduleName: "github.com/sevensolutions/traefik-oidc-auth"
      version: "v0.3.2"
# traefik-compose.yml
services:
  traefik:
    container_name: ${SERVICES_TRAEFIK_CONTAINER_NAME:-traefik}
    depends_on:
      crowdsec:
        condition: service_healthy
      socket-proxy:
        condition: service_healthy
      zitadel:
        condition: service_started
    env_file: ${ABSOLUTE_PATH}/data/traefik/.env
    image: ${SERVICES_TRAEFIK_IMAGE:-traefik}:${SERVICES_TRAEFIK_IMAGE_VERSION:-3.1}
    labels:
      traefik.enable: "true"
      traefik.http.routers.traefik-dashboard.entrypoints: websecure
      traefik.http.routers.traefik-dashboard.middlewares: default@file, oidc-auth@file
      traefik.http.routers.traefik-dashboard.rule: ${SERVICES_TRAEFIK_LABELS_TRAEFIK_HOST:-HOST(`traefik.myowndomain.com`)}
      traefik.http.routers.traefik-dashboard.service: api@internal
      traefik.http.routers.traefik-dashboard.tls: "true"
      traefik.http.routers.traefik-dashboard.tls.certresolver: http_resolver
    networks:
      crowdsec:
        ipv4_address: ${SERVICES_TRAEFIK_NETWORKS_CROWDSEC_IPV4:-172.31.127.253}
      proxy:
        ipv4_address: ${SERVICES_TRAEFIK_NETWORKS_PROXY_IPV4:-172.31.191.254}
      socket_proxy:
        ipv4_address: ${SERVICES_TRAEFIK_NETWORKS_SOCKET_PROXY_IPV4:-172.31.255.253}
    ports:
      - mode: host
        target: 80
        published: "80"
        protocol: tcp
      - mode: host
        target: 443
        published: "443"
        protocol: tcp
    restart: unless-stopped
    security_opt:
      - no-new-privileges:true
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ${ABSOLUTE_PATH}/data/traefik/traefik.yml:/etc/traefik/traefik.yml
      - ${ABSOLUTE_PATH}/data/traefik/.htpasswd:/etc/traefik/.htpasswd
      - ${ABSOLUTE_PATH}/data/traefik/certs/acme_letsencrypt.json:/etc/traefik/acme_letsencrypt.json
      - ${ABSOLUTE_PATH}/data/traefik/certs/tls_letsencrypt.json:/etc/traefik/tls_letsencrypt.json
      - ${ABSOLUTE_PATH}/data/traefik/dynamic_conf:/etc/traefik/dynamic_conf:ro
      - ${ABSOLUTE_PATH}/data/traefik/log/traefik/:/var/log/traefik/
# http.middlewares.oidc-auth.yml
http:
  middlewares:
    oidc-auth:
      plugin:
        traefik-oidc-auth:
          Provider:
            Url: "https://zitadel.myowndomain.com"
            ClientId: "ClientId@myowndomain.com"
            ClientSecret: "SuperSecret"
          Scopes: ["openid", "profile", "email"]
          Authorization:
            AssertClaims:
              - Name: "preferred_username"
                AnyOf: ["alice@gmail.com", "bob@gmail.com"]
              - Name: "roles"
                AllOf: ["admin", "media"]
              - Name: "user.first_name"
                AnyOf: ["Kevin"]
          Headers:
            MapClaims:
              - Claim: "preferred_username"
                Header: "X-Oidc-Username"
              - Claim: "sub"
                Header: "X-Oidc-Subject"

When I try to open https://traefik.myowndomain.com/, I get this response:

{
  "error": "invalid_request",
  "error_description": "The requested redirect_uri is missing in the client configuration. If you have any questions, you may contact the administrator of the application."
}

The URL I see in the browser looks correct to me; it includes ...&redirect_uri=https%3A%2F%2F....

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 20 (10 by maintainers)

Most upvoted comments

So, you’re saying I need to define each subdomain I plan to use within the Zitadel project’s redirect URIs?

Currently, I only have this entry: https://zitadel.myowndomain.com/oidc/callback.

Does that mean this specific entry isn’t needed, or am I misunderstanding?

My idea was to protect “simple” web apps (which lack their own secure login) with a single Zitadel project. This Zitadel project should handle different subdomains, like https://*.myowndomain.com. For more advanced web apps like Portainer, I’d use a dedicated project.

Maybe I’ve misunderstood how Zitadel and Traefik work together for this auth flow. I thought I could create a generic project and use it across multiple subdomains.

BTW, once we land PR #30 or similar, the plugin should support a single static callback domain for all apps, which will mean you won’t have to list every app’s redirect url in Zitadel.