I have a working config of HAProxy that captured the Authorization header in log file.
Captured authorization string looks like Basic dGVzdDp0ZXN0Cg==
.
I need to remove Basic
and convert dGVzdDp0ZXN0Cg==
from base64 to original text.
I could convert whole captured string into base64 like
%[capture.req.hdr(0),base64]
but how convert it back to original?
Part of config file:
tcp-request content capture req.hdr(Authorization) len 128
log-format "%Tl "Client"-"%ci" "ConnectsTo"-"%fi:%fp" AuthorizationHeader:%[capture.req.hdr(0),regsub(Basic\s*,)] %hs"
To remove "Basic " from line beginning and decode AuthorizationHeader from base64 to original just need add %[capture.req.hdr(0),regsub(Basic\s*,),b64dec]
Full config:
tcp-request content capture req.hdr(Authorization) len 128
log-format "Client-%ci Server-%fi:%fp AuthorizationHeader:%[capture.req.hdr(0),regsub(Basic\s*,),b64dec]"