Skip to content

feat: add basic auth middleware UI under Traefik Dynamic#4285

Open
quochuydev wants to merge 3 commits intoDokploy:canaryfrom
quochuydev:feat/traefik-basic-auth-middleware-ui
Open

feat: add basic auth middleware UI under Traefik Dynamic#4285
quochuydev wants to merge 3 commits intoDokploy:canaryfrom
quochuydev:feat/traefik-basic-auth-middleware-ui

Conversation

@quochuydev
Copy link
Copy Markdown
Contributor

@quochuydev quochuydev commented Apr 22, 2026

Lets users create and delete Traefik basicAuth middlewares from the Traefik dashboard, so compose services can reference them as <name>@file via labels without hand-editing middlewares.yml.

What is this PR about?

Adds a Basic Auth Middlewares card to the Traefik dashboard page (/dashboard/traefik) that lets users create and delete Traefik basicAuth middlewares directly in middlewares.yml from the UI.

Today, Applications can manage basic auth via Advanced → Security, but Compose apps (and anyone wanting a standalone basic auth middleware) have to SSH into the host and hand-edit YAML plus bcrypt hashes. This PR closes that gap with a generic, app-agnostic middleware manager.

The generated middleware is referenced manually as <name>@file — either in compose labels or in a domain's Middlewares field — followed by a user-initiated redeploy. Traefik picks up the YAML change live.

Checklist

Before submitting this PR, please make sure that:

  • I created a dedicated branch based on the canary branch (feat/traefik-basic-auth-middleware-ui).
  • I have read the suggestions in the CONTRIBUTING.md file.
  • I have tested this PR in my local instance.

Issues related (if applicable)

closes #4284

Screenshots (if applicable)

Screenshot 2026-04-22 at 19 25 25

Greptile Summary

This PR adds a Basic Auth Middlewares UI to the Traefik dashboard, letting users create and delete basicAuth entries in middlewares.yml without hand-editing YAML. The approach is consistent with how the rest of the codebase manages Traefik dynamic config.

  • P1 — null-config crash: loadMiddlewares() returns null for an empty middlewares.yml (no exception is thrown, so the catch is bypassed). Both createBasicAuthMiddleware and deleteBasicAuthMiddleware then dereference that null value without guarding against it, causing an unhandled TypeError on the server.

Confidence Score: 4/5

Safe to merge after fixing the null-config crash in the two new mutations.

One P1 defect: both mutating endpoints crash with a TypeError if middlewares.yml exists but is empty, because loadMiddlewares() returns null without throwing. The rest of the implementation follows existing codebase patterns and introduces no security regressions.

apps/dokploy/server/api/routers/settings.ts — null guard after loadMiddlewares() in both createBasicAuthMiddleware and deleteBasicAuthMiddleware

Reviews (1): Last reviewed commit: "[autofix.ci] apply automated fixes" | Re-trigger Greptile

Greptile also left 2 inline comments on this PR.

Lets users create and delete Traefik basicAuth middlewares from the
Traefik dashboard, so compose services can reference them as
`<name>@file` via labels without hand-editing middlewares.yml.
@quochuydev quochuydev requested a review from Siumauricio as a code owner April 22, 2026 12:28
@dosubot dosubot Bot added the size:L This PR changes 100-499 lines, ignoring generated files. label Apr 22, 2026
@dosubot dosubot Bot added the enhancement New feature or request label Apr 22, 2026
Comment thread apps/dokploy/server/api/routers/settings.ts Outdated
- Show delete spinner only on the row being deleted (track deletingName
  locally instead of sharing the mutation's isPending across all items).
- Handle null config from loadMiddlewares when middlewares.yml is empty
  (yaml.parse('') returns null) — normalize before dereferencing in
  create, and treat as NOT_FOUND in delete.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request size:L This PR changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add UI to manage Traefik basic auth middlewares

1 participant