Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

extAuth - headersToExtAuth translation case-sensitivity #3372

Closed
ecoughlan opened this issue May 12, 2024 · 2 comments · Fixed by #3420
Closed

extAuth - headersToExtAuth translation case-sensitivity #3372

ecoughlan opened this issue May 12, 2024 · 2 comments · Fixed by #3420
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Milestone

Comments

@ecoughlan
Copy link

Description:
headersToExtAuth translation case-sensitivity mismatch

Repro steps:
A config like this:

---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: SecurityPolicy
metadata:
  name: authentik-ext-auth
  namespace: default
spec:
  targetRef:
    group: gateway.networking.k8s.io
    kind: HTTPRoute
    name: httpbin
    namespace: default
  extAuth:
    headersToExtAuth:
      - Cookie
    ...

is translated to exact string matches including case. Unfortunately request headers are folded to lower-case somewhere (maybe this is the actual bug), so "Cookie" will not get forwarded to the auth backend and is silently dropped.

With this change in extauth.go I was able to make logging in work:

--- a/internal/xds/translator/extauth.go
+++ b/internal/xds/translator/extauth.go
@@ -104,6 +104,7 @@ func extAuthConfig(extAuth *ir.ExtAuth) *extauthv3.ExtAuthz {
                        MatchPattern: &matcherv3.StringMatcher_Exact{
                                Exact: header,
                        },
+                       IgnoreCase: true,
                })
        }

Environment:
gateway v1.0.1

Notes:
Maybe this should be specifiable in https://gateway.envoyproxy.io/latest/api/extension_types/#extauth instead of a stringarray instead.
The same problem might apply to headersToBackend as well.

@alexandermarston
Copy link
Contributor

We're seeing a similar problem where our application sometimes sends an Authorization header and sometimes sends an authorization header which is causing us a headache.

@arkodg
Copy link
Contributor

arkodg commented May 15, 2024

HTTP header names are case insensitive https://datatracker.ietf.org/doc/html/rfc2616#page-31 so +1 to this change

@arkodg arkodg added help wanted Extra attention is needed and removed triage labels May 15, 2024
@arkodg arkodg added this to the v1.1.0-rc1 milestone May 15, 2024
@arkodg arkodg added the good first issue Good for newcomers label May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants