Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

auth-perm

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

auth-perm

A simple level-based permission / authorization / access control

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

auth-perm

A simple level-based permission authorization

Install

npm install --save auth-perm

Usage

const perm = new Permissions({
  admins: ['adminId1', 'adminId2'], // Admin user ids
  defaultLevel: 0,                  // Default required user permission level
  authenticatedLevel = 1,           // Level assigned to authenticated users
  adminLevel = 10,                  // Level assigned to admin user
});

// Returns true if allowed.
perm.check(
  {
    p: 2,                   // User permission level required for this check
    a: ['allowedUserId1'],  // Whitelisted user ids
    b: ['blockedUserId1'],  // Blacklisted user ids
  },
  
  'sessionUserId',          // Optional user id.
                            // If provided, authenticated user level will be assigned.
                            // Also, it will be tested against whitelist and blacklist ids.
                            // If not provided, user permission level will be 0.
                            
  3                         // Optional user level.
                            // If provided, this value will be used as the user's permission level.
);

Keywords

FAQs

Package last updated on 03 May 2016

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc