Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
basicAuthVCL4.vcl
sub vcl_recv {
if (! req.http.Authorization ~ "Basic dXNlcm5hbWU6cGFzc3dvcmQ=") {
# This is checking for base64 encoded username:password combination
return(synth(401, "Authentication required"));
}
unset req.http.Authorization;
}
sub vcl_synth {
if (resp.status == 401) {
set resp.status = 401;
set resp.http.WWW-Authenticate = "Basic";
return(deliver);
}
}
@MageryThemes

This comment has been minimized.

Copy link

@MageryThemes MageryThemes commented May 22, 2018

If you want to generate base64-encoded string with login and password you can use this command:
echo -n "USER:PASSWORD" | base64

@niccolox

This comment has been minimized.

Copy link

@niccolox niccolox commented Sep 30, 2019

echo dXNlcm5hbWU6cGFzc3dvcmQ= | base64 --decode
username:password

@edysmp

This comment has been minimized.

Copy link

@edysmp edysmp commented Jun 2, 2020

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment