You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I get "invalid header" from provider-http when adding my basicAuth token (from a kubernetes secret) to the Authorization header in the DisposableRequest.
Basic auth requires a base64-encoded user+secret. So when I add my secret as a kubernetes secret I'm base64-encoding it twice. (a kubernetes secret must be added as base64, and will be decoded when read).
But I get "invalid header" when I do this in a DisposableRequest.
I have verified that my request is sent if I only base64 it once, but in those instances it sends the username:password in cleartext and I get a HTTP 401 from the 3rdparty API.
From the provider-http I see the following in the logs (after base64-encoding twice).
Warning CannotCreateExternalResource 5s managed/disposablerequest.http.crossplane.io failed to send http request: (ommitted url). : net/http: invalid header field value for "Authorization"
How can we reproduce it?
Create a kubernetes secret called "my-secret-external". This contains a user+password for calling a 3rd-party API which requires Basic authentication.
Base64-encode the username+password, and then base64 the result again (so when it is injected into the DisposableRequest as Authorization header, it will still be base64 encoded as required in the specification).
Check if a newline character is being added:
When base64 encoding without the -n flag, a newline character might get added. You can avoid this by using:
echo -n "username:password"| base64
echo -n <base64-credentials>| base64
Try encoding directly in YAML if double base64 encoding is the issue:
You can perform the second base64 encoding directly in the request using jq, which avoids manually encoding it twice. Here's an example:
What happened?
I get "invalid header" from provider-http when adding my basicAuth token (from a kubernetes secret) to the Authorization header in the DisposableRequest.
Basic auth requires a base64-encoded user+secret. So when I add my secret as a kubernetes secret I'm base64-encoding it twice. (a kubernetes secret must be added as base64, and will be decoded when read).
But I get "invalid header" when I do this in a DisposableRequest.
I have verified that my request is sent if I only base64 it once, but in those instances it sends the username:password in cleartext and I get a HTTP 401 from the 3rdparty API.
From the provider-http I see the following in the logs (after base64-encoding twice).
How can we reproduce it?
Create a kubernetes secret called "my-secret-external". This contains a user+password for calling a 3rd-party API which requires Basic authentication.
Base64-encode the username+password, and then base64 the result again (so when it is injected into the DisposableRequest as Authorization header, it will still be base64 encoded as required in the specification).
To reproduce:
echo "username:password" | base64
Result:
dXNlcm5hbWU6cGFzc3dvcmQK
dXNlcm5hbWU6cGFzc3dvcmQK
| base64Result:
ZFhObGNtNWhiV1U2Y0dGemMzZHZjbVFLCg==
Then apply this as a secret into kubernetes.
In my crossplane composition I reference the secret in the Authorization header like this:
(and according to the docs)
More complete example:
What environment did it happen in?
Crossplane version:
v1.16.0
xpkg.upbound.io/crossplane-contrib/provider-http:v1.0.5
kubectl version
): 1.28.9The text was updated successfully, but these errors were encountered: