npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

loopback-component-sec

v0.4.2

Published

A loopback security component with scoped roles management and permission access control

Downloads

72

Readme

loopback-component-sec

NPM version NPM downloads Build Status Coverage Status

A loopback security component with scoped roles management and permission access control

Introduction

loopback-component-sec using nsec enables you to add multi-tenant style access controls to a loopback application. It enables you to restrict access to model data based on a user's roles within a specific context.

The main concept is borrowed from loopback-component-access-groups.

loopback-component-sec provide a inheritable roles management and a row level access controller.

There are three types of access restrictions implemented in this component:

1) Role Resolvers

loopback-component-sec attach a dynamic Role Resolver named $sec to the application. The Role Resolver is responsible for determining whether or not a user has the relevant roles required to access data that belongs to a group context.

2) Query Filters

An 'access' Operation Hook is injected into each Group Content model. This is used to filter search results to ensure that only items that a user has access to (based on their scoped User Role Mappings) are returned.

3) Row Level Secure

A model (Group or Group context model) 'access' operation hook or connector 'execute' operation hook according to database connector is injected to add additional filter based on model permissions attached with acl.allow(). This is used to filter search results to ensure that only items that a user has access to (based on model's permission lists) are returned.

How to Install

  1. Install in you loopback project:

    $ npm install --save loopback-component-sec
  2. Create a component-config.json file in your server folder (if you don't already have one)

  3. Configure options inside component-config.json. (see configuration section)

    {
    	"loopback-component-sec": {
    		"{option}": "{value}"
    	}
    }

Usage

...Run one, or a combination of the following commands to lint and test your code:

$ npm run lint          # Lint the source code with ESLint
$ npm test              # Lint and Run unit tests with Mocha

A sample application is provided in the test directory. This demonstrates how you can integrate the component with a loopback application.

The following group roles roles are configured in the test data.

  • member
    read

  • manager
    read, write

  • admin
    read, write, delete

There are a number of test user accounts in the sample application.

  • generalUser
  • (no group roles)
  • storeAdminA
  • ($group:admin of Store A)
  • storeManagerA
  • ($group:manager of Store A)
  • storeMemberA
  • ($group:member of Store A)
  • storeAdminB
  • ($group:admin of Store B)
  • storeManagerB
  • ($group:manager of Store B)
  • storeMemberB
  • ($group:member of Store B)

Creds

License

MIT © Yuan Tao