3 ms·
Show HN: Checkpoint 401 – forward auth server in TypeScript / Deno
I wrote a forward auth server in TypeScript and Deno.
I've written several forward auth servers before but they have always been specifically written for that application. I wanted something more generalised that I could re-use.
What is forward auth? Web servers likes Nginx and Caddy and Traefik have a configuration option in which inbound requests are sent to another server before they are allowed. A 200 response from that server means the request is authorised, anything else results in the web server rejecting the request.
This is a good thing because it means you can put all your auth code in one place, and that the auth code can focus purely on the job of authing inbound requests.
Checkpoint 401 aims to be extremely simple - you define a route.json which contains 3 things, the method, the URL pattern to match against and the filename of a TypeScript function to execute against that request. Checkpoint 401 requires that your URL pattern comply with the URL pattern API here: https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/URLPattern https://developer.mozilla.org/en-US/docs/Web/API/URLPattern/...
Your TypeScript function must return a boolean to pass/fail the auth request.
That's all there is to it. It is brand new and completely untested so it's really only for skilled TypeScript developers at the moment - and I suggest that if you're going to use it then first read through the code and satisify yourself that it is good - it's only 500 lines: https://raw.githubusercontent.com/crowdwave/checkpoint401/master/checkpoint401.ts https://raw.githubusercontent.com/crowdwave/checkpoint401/ma...
- andrewstuart 2y agoHere is the link to the source code: https://raw.githubusercontent.com/crowdwave/checkpoint401/master/checkpoint401.ts https://raw.githubusercontent.com/crowdwave/checkpoint401/ma... And the github repo: https://github.com/crowdwave/checkpoint401 https://github.com/crowdwave/checkpoint401
- paulddraper 2y agoError details are good.
- andrewstuart 2y agoWhat do you mean?
- paulddraper 2y agoInstead of just a pass/fail, it's often helpful to describe why it failed. Especially with something as difficult to diagnose as auth. Missing auth, malformed auth, invalid signature, expired, etc.
- andrewstuart 2y agoAgreed. I'll add a response value.