All Projects → dashersw → hakki

dashersw / hakki

Licence: MIT license
An opinionated, modern, and scalable alternative to node_acl.

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to hakki

spicedb
Open Source, Google Zanzibar-inspired fine-grained permissions database
Stars: ✭ 3,358 (+10075.76%)
Mutual labels:  acl
mrnet
Building an ACL tear detector to spot knee injuries from MRIs with PyTorch (MRNet)
Stars: ✭ 98 (+196.97%)
Mutual labels:  acl
gfwlist.acl
🌐gfwlist in acl format, compatible with SSR, update daily by travis CI
Stars: ✭ 48 (+45.45%)
Mutual labels:  acl
loopback-component-mq
Loopback Component for working with a Message Queue
Stars: ✭ 19 (-42.42%)
Mutual labels:  acl
dynamic-data-and-capabilities
[ARCHIVED] Dynamic Data and Capabilities in IPFS Working Group
Stars: ✭ 57 (+72.73%)
Mutual labels:  acl
nova-permissions
Add Permissions based authorization for your Nova installation via User-based Roles and Permissions. Roles are defined in the database whereas Permissions are defined in the code base.
Stars: ✭ 115 (+248.48%)
Mutual labels:  acl
Chi Authz
chi-authz is an authorization middleware for Chi
Stars: ✭ 248 (+651.52%)
Mutual labels:  acl
WendzelNNTPd
A usable and IPv6-ready Usenet-server (NNTP daemon). It is portable (Linux/*BSD/*nix), supports AUTHINFO authentication, contains ACL as well as role based ACL and provides "invisible" newsgroups. It can run on MySQL and SQLite backends.
Stars: ✭ 43 (+30.3%)
Mutual labels:  acl
emqx-auth-http
EMQ X HTTP Authentication/ACL Plugin
Stars: ✭ 42 (+27.27%)
Mutual labels:  acl
caddy-security
🔐 Authentication, Authorization, and Accounting (AAA) App and Plugin for Caddy v2. 💎 Implements Form-Based, Basic, Local, LDAP, OpenID Connect, OAuth 2.0 (Github, Google, Facebook, Okta, etc.), SAML Authentication. MFA/2FA with App Authenticators and Yubico. 💎 Authorization with JWT/PASETO tokens. 🔐
Stars: ✭ 696 (+2009.09%)
Mutual labels:  acl
kong-plugin-jwt-crafter
Kong plugin to automatically issue a JWT token if consumer is authenticated and has a JWT credential
Stars: ✭ 35 (+6.06%)
Mutual labels:  acl
event-extraction-paper
Papers from top conferences and journals for event extraction in recent years
Stars: ✭ 54 (+63.64%)
Mutual labels:  acl
please
please, a sudo clone
Stars: ✭ 40 (+21.21%)
Mutual labels:  acl
TradeTheEvent
Implementation of "Trade the Event: Corporate Events Detection for News-Based Event-Driven Trading." In Findings of ACL2021
Stars: ✭ 64 (+93.94%)
Mutual labels:  acl
laravel-zend-acl
Adds ACL to Laravel via Zend\Permissions\Acl component.
Stars: ✭ 41 (+24.24%)
Mutual labels:  acl
Rbac
Hierarchical Role-Based Access Control for Node.js
Stars: ✭ 254 (+669.7%)
Mutual labels:  acl
consul-acl-client-tutorial
Example how to configure and use Consul client agent with ACL
Stars: ✭ 26 (-21.21%)
Mutual labels:  acl
loopback-object-acl
Object-level ACL for Loopback Node.js framework
Stars: ✭ 13 (-60.61%)
Mutual labels:  acl
express-objection-starter
an opinionated, production-ready, isomorphic express/knex/objection starter with centralized configuration
Stars: ✭ 19 (-42.42%)
Mutual labels:  acl
rbac-tool
Rapid7 | insightCloudSec | Kubernetes RBAC Power Toys - Visualize, Analyze, Generate & Query
Stars: ✭ 546 (+1554.55%)
Mutual labels:  acl

hakki

An opinionated, modern, and scalable alternative to node_acl.

Features

  • Provides the same functionality with node_acl except for middleware
  • Works with promises and async/await out of the box instead of callbacks
  • Requires and works with mongoose
  • Built specifically for MongoDB with aggregation features
  • Scalable architecture to support millions of operations
  • Supports wildcard resources for a lighter database

Migrating from v1 to v2

As of version 2 hakki runs with an in-memory backend by default. This means mongoose is an optional dependency, and one can use hakki in projects that don't use MongoDB. This is particularly useful for unit testing purposes where hakki is required but running MongoDB isn't feasible.

In-memory backend is now the default and users are required to import and then call hakki with an options object. Check out Providing mongoose for instructions on how to use the mongoose backend. Simply requiring hakki without calling it with an options object will result in the default behavior of using in-memory backend.

Motivation

node_acl is great until you need to scale it with MongoDB. It's originally built for redis, and MongoDB backend is problematic at scale where you modify the same document that holds 200,000 properties in it. The fact that it works on a MongoDB connection makes it hard to operate it with clusters, as well.

hakki addresses these concerns, respects your MongoDB connection logic with mongoose, and offers a modern, scalable experience both during development and for your infrastructure.

Usage

Installation

npm install hakki

Providing mongoose

Since mongoose and MongoDB in general has a lot of connection options, and hakki only wants to focus on ACL, it expects you to have a working mongoose connection. It will create four collections in the database of your connection: acl_allows, acl_role_parents, acl_role_users and acl_users.

Just require mongoose and connect to database however you wish:

const mongoose = require('mongoose')
const hakki = require('hakki')({ backend: 'mongoose' })

mongoose.connect('mongodb://localhost:27017/acl', { useNewUrlParser: true })

After this point, hakki is ready to use.

Example

await hakki.allow(['developer', 'guest'], ['branches', 'tags'], ['list', 'fetch'])
await hakki.allow('master', ['branches', 'tags'], 'push')
await hakki.addRoleParents('master', ['developer', 'guest'])
await hakki.addUserRoles('user1', 'master')

let perms = await hakki.allowedPermissions('user1', ['branches', 'tags'])
console.log(perms)
/*
{
tags: [ 'fetch', 'push', 'list' ],
branches: [ 'fetch', 'push', 'list' ]
}
*/

API

Hakki supports the same API footprint as node_acl with the following functions:

  • addUserRoles

  • removeUserRoles

  • userRoles

  • roleUsers

  • hasRole

  • removeRole

  • allow

  • removeAllow

  • allowedPermissions

  • isAllowed

  • areAnyRolesAllowed

  • whatResources

  • removeResource

  • addRoleParents

  • removeRoleParents

  • isRole

  • getDistinctRoles

  • getDistinctPermissions

    isRole is a new API that mimicks the behavior of a hasRole call for a user for parent roles as well. Technically when one uses addRoleParents, a child role attains an is-a relationship with the parent. However, this isn't reflected in userRoles or hasRole, but in isAllowed or allowedPermissions. isRole is introduced to at least partially cover for this.

    getDistinctRoles & getDistinctPermissions are added as helper functions to be able to check the possible options before creating new roles and permissions.

All the functions use promises and no callbacks. So if you rely on callbacks with node_acl, then you will have to refactor your code to use promises, and better yet, async / await.

Also, currently there's no Express middleware support.

Please refer to node_acl's README for detailed documentation.

MIT License

Copyright (c) 2018 Armagan Amcalar

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].