https://github.com/mendhak/express-hmac-example
Example of Express app with HMAC protected route, and examples of how to invoke it in Node and C#
https://github.com/mendhak/express-hmac-example
Last synced: 7 months ago
JSON representation
Example of Express app with HMAC protected route, and examples of how to invoke it in Node and C#
- Host: GitHub
- URL: https://github.com/mendhak/express-hmac-example
- Owner: mendhak
- Created: 2020-09-20T14:50:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-06T15:51:53.000Z (over 1 year ago)
- Last Synced: 2025-04-06T00:27:34.308Z (9 months ago)
- Language: JavaScript
- Size: 15.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Install dependencies
```
npm install
```
Start the Express app
```
npm start
```
Try browsing to http://localhost:3000/protected and get blocked. It requires an [HMAC header](https://github.com/connorjburton/hmac-auth-express#generating-your-hmac-digest).
---
Generate header using C#
```
dotnet run
```
Call using C# generated header
```
curl -v -X POST -H "Content-Type: application/json" -H "Authentication: $(dotnet run)" http://localhost:3000/protected --data '{"a":"b"}'
```
Generate header using NodeJS
```
node test.js
```
Call using NodeJS generated header
```
curl -v -X POST -H "Content-Type: application/json" -H "Authentication: $(node test.js)" http://localhost:3000/protected --data '{"a":"b"}'
```