Skip to content

Instantly share code, notes, and snippets.

@ThijsFeryn ThijsFeryn/call_jwt.vcl
Last active Feb 13, 2017

Embed
What would you like to do?
Call the custom-defined JWT VCL procedure that checks the validity of a JSON Web Token. This VCL snippet requires vmod_digest and https://gist.github.com/ThijsFeryn/b745c42dbfa328d702b8dbba8777aee2
vcl 4.0;
import digest;
backend default {
.host = "localhost";
.port = "8080";
}
include "jwt.vcl";
sub vcl_recv {
if ((req.method != "GET" && req.method != "HEAD") || req.http.Authorization) {
return (pass);
}
call jwt;
if(req.url == "/private" && req.http.X-Login != "true") {
return(synth(302,"/login"));
}
return(hash);
}
sub vcl_synth {
if (resp.status == 301 || resp.status == 302) {
set resp.http.location = resp.reason;
set resp.reason = "Moved";
return (deliver);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.