This repository contains companion code and examples for the SENG 401 "Practical Crypto" lecture. It includes three small demo projects that show different ways to implement and validate common authentication schemes (API keys, HTTP Basic, JWT, HMAC signatures, OAuth2) and tooling for signing/verifying requests.
-
flask-app/— a Python Flask server demonstrating several auth approaches. Seeflask-app/EXAMPLES.mdandflask-app/README.mdfor how to run the server and example curl commands. Theflask-app/utilities/package includes utilities for JWT handling and request signatures, andflask-app/certs/contains example self-signed certs for local HTTPS testing. -
nextjs-app/— a Next.js (TypeScript) frontend that demonstrates client-side examples and a tiny API that exercises the same auth patterns. Checknextjs-app/README.mdand theapp/api/*/route.tsendpoints. Components undernextjs-app/components/show how to build authenticated calls from the browser. -
nodejs-express/— a Node.js/Express server with equivalent examples to the Flask app. Seenodejs-express/EXAMPLES.mdandnodejs-express/README.mdfor usage. Helpers are innodejs-express/utils.jsand thescripts/folder contains utility scripts (for example request signing).
- Flask app examples:
flask-app/EXAMPLES.md(curl examples and how to runflask-app/app.py). - Next.js examples:
nextjs-app/README.mdand the API route handlers innextjs-app/app/api/(seejwt-auth,api-signature,api-key,basic-auth,token). - Node/Express examples:
nodejs-express/EXAMPLES.mdandnodejs-express/index.js/nodejs-express/app.jsfor server entry points.
-
Flask app (requires Python 3.11+ and the dependencies in
flask-app/requirements.txt): install requirements and run the server (example):- Create a venv, install dependencies, then run
flask-app/app.py. Theflask-app/EXAMPLES.mdfile contains example curl commands, including HTTPS examples using the bundledflask-app/certs/self-signed certs.
- Create a venv, install dependencies, then run
-
Next.js app (requires Node.js & npm/yarn): from
nextjs-app/runnpm installthennpm run dev(seenextjs-app/README.mdfor details). The local API routes mirror the auth demos. -
Node/Express app (requires Node.js & npm): from
nodejs-express/runnpm installthennode index.js(ornode app.js) — seenodejs-express/EXAMPLES.mdfor example requests.
If you want to add more examples or improve explanations, please submit a PR. Small, focused examples with clear README updates are easiest to review.
MIT License