@aaqu/node-red-digest-auth 0.2.0
Node-RED nodes for HTTP Digest Authentication (RFC 7616)
@aaqu/node-red-digest-auth
Node-RED nodes for HTTP Digest Authentication (RFC 7616).
Installation
npm install @aaqu/node-red-digest-auth
Or install via the Node-RED Palette Manager.
Development
cd ~/.node-red
npm install /path/to/node-red-digest-auth
Nodes
digest-auth
Middleware node that processes 401 responses and generates Digest Authorization headers.
Inputs:
msg.statusCode- Should be 401msg.headers['www-authenticate']- Digest challenge from server (response headers)msg.url- Request URLmsg.method- HTTP method (optional, default: GET)msg.authHeaders- Custom request headers to preserve (optional)msg.payload- Request body for POST/PUT (optional)
Outputs:
msg.url- Original request URLmsg.method- HTTP methodmsg.headers- Object withauthHeaders+Authorizationheadermsg.payload- Preserved from input (if present)
digest-auth-credentials
Configuration node for storing username and password securely.
Supported Algorithms
| Algorithm | Status |
|---|---|
| SHA-256 | Recommended |
| SHA-256-sess | Supported |
| SHA-512-256 | Supported |
| SHA-512-256-sess | Supported |
| MD5 | Legacy (not recommended) |
| MD5-sess | Legacy |
Example Flow
[inject] → [http request] → [switch: 401?] → [digest-auth] → [http request] → [debug]
↓
[debug] (other status)
- Inject - Triggers the request with URL
- HTTP Request - Sends initial unauthenticated request
- Switch - Checks if response is 401
- digest-auth - Generates Authorization header from WWW-Authenticate
- HTTP Request - Retries with authentication
- Debug - Shows the result
Import Example
Go to Menu → Import → Examples → @aaqu/node-red-digest-auth to import a ready-to-use example flow.
Configuration
digest-auth node
| Property | Description |
|---|---|
| Credentials | Reference to digest-auth-credentials config node |
| Algorithm | Preferred algorithm (SHA-256 recommended) |
| QoP | Quality of Protection: auth or auth-int |
digest-auth-credentials node
| Property | Description |
|---|---|
| Name | Optional display name |
| Username | Authentication username |
| Password | Authentication password (stored securely) |
Using Custom Headers
To send custom headers (like Content-Type, X-API-Key, etc.) with your authenticated request:
Set
msg.authHeadersin your inject or function node:msg.authHeaders = { "Content-Type": "application/json", "X-Custom-Header": "value" };Configure your first HTTP Request node to use
msg.authHeadersfor outgoing headersAfter digest-auth processes the 401 response,
msg.headerswill contain:- All headers from
msg.authHeaders - The generated
Authorizationheader
- All headers from
The second HTTP Request node uses
msg.headersby default
API
lib/crypto.js
const { calculateDigestResponse, generateCnonce } = require('@aaqu/node-red-digest-auth/lib/crypto');
const response = calculateDigestResponse({
algorithm: 'SHA-256',
username: 'user',
realm: 'example.org',
password: 'secret',
method: 'GET',
uri: '/path',
nonce: 'server-nonce',
nc: '00000001',
cnonce: generateCnonce(),
qop: 'auth'
});
lib/parser.js
const { parseWWWAuthenticate } = require('@aaqu/node-red-digest-auth/lib/parser');
const challenge = parseWWWAuthenticate('Digest realm="test", nonce="abc123", qop="auth"');
// { realm: 'test', nonce: 'abc123', qop: ['auth'], algorithm: 'MD5' }
lib/formatter.js
const { formatAuthorizationHeader } = require('@aaqu/node-red-digest-auth/lib/formatter');
const header = formatAuthorizationHeader({
username: 'user',
realm: 'example.org',
nonce: 'server-nonce',
uri: '/path',
algorithm: 'SHA-256',
nc: '00000001',
cnonce: 'client-nonce',
qop: 'auth',
response: 'calculated-hash'
});
// 'Digest username="user", realm="example.org", ...'
Security Notes
- Use SHA-256 - MD5 is deprecated and should only be used for legacy systems
- Always use TLS - Digest Auth does not protect against MITM attacks
- Credentials are stored securely - Not exported with flows
References
Changelog
0.2.0 (2026-01-29)
- Breaking: Clean output from digest-auth node - returns only
url,method,headers, andpayload - Added
msg.authHeaderssupport for custom headers preservation - Custom headers from
msg.authHeadersare merged withAuthorizationin outputmsg.headers - Removed
msg.digestAuthdebug object from output - Updated documentation and example flow
0.1.3
- Fixed npm publish warnings (repository URL, added bugs and homepage fields)
- Renamed example file to lowercase (basic-digest-auth.json)
0.1.2
- Fixed GitHub publish workflow
0.1.1
- Testing GitHub Actions
- Updated package.json with git repository URL
- Fixed typos
0.1.0
- Initial release
License
MIT