New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

@permify/permify-express-middleware

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

@permify/permify-express-middleware

Expressjs Middleware for authorization check using the Permify API

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Permify Express.js Authorization Middleware

Perform authorization check in your Express.js API endpoints using Permify

npm

Installation

Use npm to install:

npm install @permify/permify-express-middleware

Use yarn to install:

yarn add @permify/permify-express-middleware

Usage

Creating Middleware

Call createMiddleware function with your coresponding keys to get a configured middleware function isAuthorized:

const Permify = require("@permify/permify-express-middleware");
const { isAuthorized } = Permify.createMiddleware({"workspace_id", "private_API_token"});

Using the IsAuthorized

Once you've initialized the middleware as shown above, you can use isAuthorized middleware to protect your API routes.

Parameters

  • PolicyName (mandatory)

Custom Permify Policy name.

  • UserID (mandatory)

Id of the User

  • ResourceID (optional)

Id of the Resource, mandatory if any resource used or accessed when creating Rule.

  • ResourceType (optional)

Type or name of the Resource, mandatory if any resource used or accessed when creating Rule.

// Example case: Is user has a access to see specific contact details or not.
// We pass optional params resource id and resource type 
// because of the condition: is user contact itself (resource owner)
app.get(
  "/api/contact/:contactId",
  isAuthorized("contact-show", req.user.id, req.params.contactId, "contact"),
  (req, res) => {
    const { contactId } = req.params;
    const contact = geContact(contactId);

    if (!contact) {
      res.sendStatus(404);
      return;
    }

    res.json(contact);
  }
);

Documentation

FAQs

Package last updated on 21 Mar 2022

Did you know?

Socket

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