Socket
Socket
Sign inDemoInstall

q3-core-composer

Package Overview
Dependencies
315
Maintainers
1
Versions
286
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    q3-core-composer

This package registers a few methods onto the request object, most of which help with authenticating and authorizing.


Version published
Weekly downloads
87
increased by295.45%
Maintainers
1
Install size
27.8 MB
Created
Weekly downloads
 

Readme

Source

Composer

API

Middleware

This package registers a few methods onto the request object, most of which help with authenticating and authorizing.

Request.authorizeBody()

Redact the request's body to safely update documents.

Parameters
  • «Object(optional)» A document to consider during redaction. Useful for triggering test cases with conditional access control grants.
  • «String(optional)» A collection to query for grants. Q3-core-rest automates this value's assignment.
  • «String(optional)» A field under which the body should be tested (i.e. sub-documents). Q3-core-rest automates this value's assignment.
  • «String(optional)» An ID to load a sub-document into the document context. Useful for triggering test cases on nested access control grants.
Returns
  • «Object» The redacted request body
Example
module.exports = async function controller(req, res) {
  const doc = await Model.findById(req.id);
  const subdoc = doc;

  const body = req.authorizeBody(
    doc, // the parent document
    'test-collection', // the collection to pull grants from
    'sample', // the sub-document name
    req.sampleId, // the sub-document id
  );

  doc.sample.id(req.sampleId).set(body);
  await doc.save();

  res.status(200).json({
    ok: 1,
  });
};

FAQs

Last updated on 17 Mar 2023

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc