Skip to content

Instantly share code, notes, and snippets.

@section-io-gists
Last active June 2, 2020 01:50
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save section-io-gists/f553f548245848387feb200de709bc90 to your computer and use it in GitHub Desktop.
Save section-io-gists/f553f548245848387feb200de709bc90 to your computer and use it in GitHub Desktop.
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
Copy link

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

@niccolox
Copy link

echo dXNlcm5hbWU6cGFzc3dvcmQ= | base64 --decode
username:password

@edysmp
Copy link

edysmp commented Jun 2, 2020

Thanks

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