Nerdy Programmers Mingling

    @personaspace/server-acl-middleware
    TypeScript icon, indicating that this package has built-in type declarations

    0.1.2 • Public • Published

    PersonaSpace ACL Middleware

    For Node.js server

    CircleCI codecov Known Vulnerabilities JavaScript Style Guide

    A package containing default middleware and handling of middleware for PersonaSpace Node.js servers.

    PersonaSpace uses a powerful ACL implementation that give an owner unparalleled control over which visitors can interact with their data, where visitors can access their data from, and when visitors can access it. @personaspace/server-acl-middleware contains the ACL middleware that can modify an ACL dynamically based on request data, date, time, etc...

    This package provides only the middleware ACLs. The @personaspace/server-acl package handles resolution of ACLs of a visitor's access to the data. The @personaspace/server-resource package handles validation of the visitor's access to the data.

    Installation

    Install @personaspace/server-acl-middleware using npm.

    npm i @personaspace/server-acl-middleware
    

    Usage

    //  "request" is the web request on a PersonaSpace server.
    import { processMiddleware } from "@personaspace/server-acl-middleware";
    import { onDomain } from "@personaspace/server-acl-middleware-ondomain";
    
    const req = { headers: { host: "example.com" } };
    const permissions = {
      create: {
        enforce: false,
        result: true,
      },
      read: {
        enforce: true,
        result: false,
      },
    };
    const permObjs = [
      {
        enforce: true,
        middleware: "onDomain",
        params: ["example.com"],
        result: false,
      },
      {
        enforce: false,
        result: true,
      },
    ];
    processMiddleware(req, "create", permissions, permObjs, [onDomain]);

    Documentation

    Documentation is located at https://personaspace.github.io/node-server-acl-middleware. For issues with the documentation, please Create a new issue.

    Contributing to PersonaSpace

    PersonaSpace is a large project and contributors are welcome. Thank you for your support and efforts!

    There are a lot of ways to contribute:

    Be sure to look at CONTRIBUTING.md.

    License

    PersonaSpace is licensed under the MIT License.

    Install

    npm i @personaspace/server-acl-middleware

    DownloadsWeekly Downloads

    2

    Version

    0.1.2

    License

    MIT

    Unpacked Size

    19.5 kB

    Total Files

    16

    Last publish

    Collaborators

    • bntly