Skip to content

BUG/MINOR: rules: apply SSL redirect before basic auth#821

Open
dragoangel wants to merge 1 commit into
haproxytech:masterfrom
dragoangel:fix/order-of-ssl-redirect-and-auth
Open

BUG/MINOR: rules: apply SSL redirect before basic auth#821
dragoangel wants to merge 1 commit into
haproxytech:masterfrom
dragoangel:fix/order-of-ssl-redirect-and-auth

Conversation

@dragoangel

@dragoangel dragoangel commented Jun 23, 2026

Copy link
Copy Markdown

Summary

Fixes ordering of HTTP request rules so redirect executes before auth for ingress flows using SSL redirect.

Problem

Current ordering can challenge basic auth on HTTP first, then redirect, which is insecure and causes wrong behavior for issue #807 scenario.

What changed

  • Reordered rule priority to place redirect before auth in types.go
  • Added rule-priority regression test in types_test.go
  • Added end-to-end rules-assembly regression test in order_refresh_test.go validating final order is: redirect, then auth

Validation

go test ./pkg/haproxy/rules

Verified runtime test output order during debugging: redirect first, auth second.

Impact

Behavior change is ordering of redirect vs auth vs other directives.

Other options considered

A possible alternative to rule reordering is to avoid rendering basic auth on the HTTP (non-TLS) frontend when SSL redirect is enabled for the ingress. In that model, the HTTP frontend would only perform redirect and would not pass traffic directly, so basic auth on HTTP would not be needed. If an ingress has basic auth but does not enable TLS redirect, then basic auth would still be rendered on HTTP for that ingress.

Trade-offs

The current PR approach (redirect before auth) also makes redirect happen before other HTTP request rules such as rate limits. This may be desirable for security/UX, but it can also change expected behavior for users who rely on rate limiting before redirect. For transparency, this alternative is highlighted as a valid implementation path and, if maintainers prefer it, I can implement it either in this PR or in a dedicated follow-up PR.

Expected result

Users are redirected to HTTPS before basic-auth challenge.

…ntend

Prevents basic-auth challenge on plain HTTP before TLS redirect, resolves haproxytech#807

Signed-off-by: Dmytro Alieksieiev <1865999+dragoangel@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant