
Security News
Deno 2.2 Improves Dependency Management and Expands Node.js Compatibility
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
cf-auth-middleware
Advanced tools
Authentication middleware for APIs using cf-auth-provider
npm install --save cf-auth-middleware
var express = require('express')
, createAuthMiddleware = require('cf-auth-middleware')
, authProvider = require('cf-auth-provider')(myCollection, hashFn)
var app = express()
, authMiddleware = createAuthMiddleware(authProvider)
app.get('/private', authMiddleware, function (req, res) {
// This route is only accessible to users that are
// able to authenticate with the given authProvider
})
An authenticated request must contain either the following headers:
Content-Type: 'application/json'
x-cf-date: 'Tue, 05 Nov 2013 12:22:23 GMT'
authorization: 'Catfish {authorizing entity id}:{signed request}'
OR
It must contain the following query string keys:
?authorization={authorizing entity id}:{signed request}&x-cf-date=1423481045233
You can also specifiy a custom TTL for the request. This can be sent in either the headers or the query string:
Content-Type: 'application/json'
x-cf-date: 'Tue, 05 Nov 2013 12:22:23 GMT'
x-cf-ttl: '120000'
authorization: 'Catfish {authorizing entity id}:{signed request}'
?authorization={authorizing entity id}:{signed request}&x-cf-date=1423481045233&x-cf-ttl=120000
The client must sign requests with the cf-signature module.
authProvider
is an instance of cf-auth-provider
.
Options:
options.logger
: an object with debug()
, info()
, warn()
, error()
. Defaults to console
.options.reqProperty
: the authed client's id is stored on the request object: req[options.reqProperty]
. Defaults to authedClient
.options.ignoreQueryKeys
: an array of keys to ignore when comparing the request to the signature.
This is useful when requests get augmented by unknown cache-busting values. Defaults to []
.Built by developers at Clock.
Licensed under the New BSD License
FAQs
Authentication middleware for APIs using cf-auth-provider
The npm package cf-auth-middleware receives a total of 98 weekly downloads. As such, cf-auth-middleware popularity was classified as not popular.
We found that cf-auth-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Deno 2.2 enhances Node.js compatibility, improves dependency management, adds OpenTelemetry support, and expands linting and task automation for developers.
Security News
React's CRA deprecation announcement sparked community criticism over framework recommendations, leading to quick updates acknowledging build tools like Vite as valid alternatives.
Security News
Ransomware payment rates hit an all-time low in 2024 as law enforcement crackdowns, stronger defenses, and shifting policies make attacks riskier and less profitable.