Last active
February 13, 2017 09:58
-
-
Save ThijsFeryn/0b1bd4337c934ac77bc6759dc38a6a11 to your computer and use it in GitHub Desktop.
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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