Security News
cURL Project and Go Security Teams Reject CVSS as Broken
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
hapi-field-auth
Advanced tools
Hapi plugin for field-level authorization.
npm install hapi-field-auth
This plugin provides field-level authorization (not authentication)
for Hapi routes -- particularly for PATCH routes.
If the request payload has fields with special constraints
in respect to the scope
of the authenticated user,
this plugin allows to restrict access on field-level.
A prerequisite is authentication -- use any authentication plugin, e.g., hapi-auth-basic
.
It is expected that authentication sets request.route.auth.credentials.scope
to the request object.
Dynamic scopes referring to the request object (query, params, payload, and credentials)
are supported, e.g., user-{params.id}
. Prefix characters !
and +
are not (yet) supported.
Register the plugin with Hapi server like this:
const Hapi = require('hapi');
const hapiAuthBasic = require('hapi-auth-basic');
const hapiFieldAuth = require('hapi-field-auth');
const server = new Hapi.Server({
port: 3000,
});
const provision = async () => {
await server.register([hapiAuthBasic, hapiFieldAuth]);
// ...
await server.start();
};
provision();
Your route configuration may look like this:
server.route({
method: 'PATCH',
path: '/example',
options: {
auth: {
access: { // route-level auth -> HTTP 401/403
scope: ['write', 'write.extended'], // multiple scopes on route-level
},
},
validate: {
payload: ExampleSchema, // Joi schema validation -> HTTP 400
},
plugins: {
'hapi-field-auth': [{ // field-level authorization -> HTTP 403
fields: ['myProtectedField'], // request payload properties
scope: ['write.extended'], // restricted scopes on field-level
}],
},
},
handler: function (request, h) {
// ...
}
});
This plugin does not have any options.
FAQs
Hapi plug-in for field-level authorization
The npm package hapi-field-auth receives a total of 78 weekly downloads. As such, hapi-field-auth popularity was classified as not popular.
We found that hapi-field-auth demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
cURL and Go security teams are publicly rejecting CVSS as flawed for assessing vulnerabilities and are calling for more accurate, context-aware approaches.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.