JavaScript authorization libraries

Updated Nov 2026

JavaScript authorization libraries decide whether a user may perform an action on a resource. Some evaluate policy rules inside the application, while others send each check to a separate permission service. These libraries enforce who can view, edit, or delete records in SaaS products, admin tools, and internal platforms.

Popularity

@aws-sdk/client-iam has the most monthly downloads in this comparison, at 22.6M. That count covers every IAM operation.

LibraryMonthly downloadsStarsLast releaseLicense
@aws-sdk/client-iam
22.6M
3.7KNov 2026Apache-2.0
CASL
10.2M
7.1KNov 2026MIT
OpenFGA
4.1M
91Nov 2026Apache-2.0
@aws-sdk/client-iot
3.7M
3.7KNov 2026Apache-2.0
@backstage/plugin-permission-node
3.0M
34.9KNov 2026Apache-2.0
Authzed
2.1M
63Oct 2025Apache-2.0
@azure/arm-authorization
1.3M
2.3KApr 2023MIT
Casbin
980.6K
2.9KJun 2026Apache-2.0
Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

Libraries and code examples

@aws-sdk/client-iam

Calls the AWS Identity and Access Management (IAM) service from Node.js, browsers, and React Native.

Downloads / mo
22.6M
Stars
3.7K
Last release
3.1172.0
License
Apache-2.0
$ npm install @aws-sdk/client-iam
import { IAMClient, SimulatePrincipalPolicyCommand } from '@aws-sdk/client-iam';

const client = new IAMClient({ region: 'us-east-1' });
const result = await client.send(new SimulatePrincipalPolicyCommand({
  PolicySourceArn: 'arn:aws:iam::123456789012:role/example',
  ActionNames: ['s3:GetObject'],
  ResourceArns: ['arn:aws:s3:::example-bucket/*'],
}));

@aws-sdk/client-iam examples

From open-source projects on GitHub
export const attachRolePolicy = (policyArn, roleName) => {
  const command = new AttachRolePolicyCommand({
    PolicyArn: policyArn,
    RoleName: roleName,
  });

  return client.send(command);
};

Defines and checks JavaScript permissions using actions, subjects, fields, and object conditions.

Downloads / mo
10.2M
Stars
7.1K
Last release
7.1.3
License
MIT

Strengths

  • Restricts actions by object attributes. Allow an action only when the object matches the configured conditions.
  • Restricts changes to selected fields. Authorize selected fields without granting changes to the entire record.

Limitations

  • Type checks need object checks. Check the actual object before allowing access to a specific record.
  • Plain objects need trusted types. Use subject with a type chosen by trusted application code.

Quickstart

From en.md
$ npm install @casl/ability
import { createMongoAbility } from '@casl/ability';

const ability = createMongoAbility([{ action: 'read', subject: 'Article' }]);
const allowed = ability.can('read', 'Article');

CASL examples

From open-source projects on GitHub
export function defineAbilityFor(user: { id: number }) {
  return defineAbility((can, cannot) => {
    can('read', 'Post');
    can('update', 'Post', ['title', 'body'], { authorId: user.id });
    cannot('update', 'Post', { published: true });
  });
}

OpenFGA

Connects JavaScript applications to an OpenFGA server for relationship-based authorization checks.

Downloads / mo
4.1M
Stars
91
Last release
0.9.8
License
Apache-2.0

Strengths

  • Checks relationship-based permissions. Check whether a user has a particular relation to an object.
  • Lists accessible objects. Retrieve objects a user can access through a chosen relation.

Limitations

  • Requires an OpenFGA server. Connect the SDK to an OpenFGA API and store.
  • Chunked writes can partially succeed. Inspect per-operation results when transaction mode is disabled.

Quickstart

From README.md
$ npm install @openfga/sdk
const { OpenFgaClient } = require('@openfga/sdk'); // OR import { OpenFgaClient } from '@openfga/sdk';

const fgaClient = new OpenFgaClient({
  apiUrl: process.env.FGA_API_URL, // required
  storeId: process.env.FGA_STORE_ID, // not needed when calling `CreateStore` or `ListStores`
  authorizationModelId: process.env.FGA_MODEL_ID, // Optional, can be overridden per request
});

const result = await fgaClient.check({
  user: "user:anne",
  relation: "viewer",
  object: "document:roadmap",
});

@aws-sdk/client-iot

Calls the AWS IoT service from Node.js, browsers, and React Native.

Downloads / mo
3.7M
Stars
3.7K
Last release
3.1172.0
License
Apache-2.0
$ npm install @aws-sdk/client-iot
import { IoTClient, TestAuthorizationCommand } from '@aws-sdk/client-iot';

const client = new IoTClient({ region: 'us-east-1' });
const result = await client.send(new TestAuthorizationCommand({
  principal: 'arn:aws:iot:us-east-1:123456789012:cert/example',
  authInfos: [{
    actionType: 'PUBLISH',
    resources: ['arn:aws:iot:us-east-1:123456789012:topic/example'],
  }],
}));

@backstage/plugin-permission-node

Supplies permission and authorization utilities for Backstage backend plugins.

Downloads / mo
3.0M
Stars
34.9K
Last release
0.11.6
License
Apache-2.0
$ npm install @backstage/plugin-permission-node @backstage/plugin-permission-common
import { createConditionAuthorizer } from '@backstage/plugin-permission-node';
import { AuthorizeResult } from '@backstage/plugin-permission-common';

const authorize = createConditionAuthorizer([]);
const allowed = authorize({ result: AuthorizeResult.DENY }, undefined);

Connects Node.js applications to the Authzed permission service.

Downloads / mo
2.1M
Stars
63
Last release
1.6.1
License
Apache-2.0

Quickstart

From README.md
$ npm i @authzed/authzed-node
import { v1 } from "@authzed/authzed-node";

const client = v1.NewClient("token");

// Create the relationship between the resource and the user.
const firstPost = v1.ObjectReference.create({
  objectType: "blog/post",
  objectId: "1",
});

// Create the user reference.
const emilia = v1.ObjectReference.create({
  objectType: "blog/user",
  objectId: "emilia",
});

// Create the subject reference using the user reference
const subject = v1.SubjectReference.create({
  object: emilia,
});

const checkPermissionRequest = v1.CheckPermissionRequest.create({
  resource: firstPost,
  permission: "read",
  subject,
});

client.checkPermission(checkPermissionRequest, (err, response) => {
  console.log(response);
  console.log(err);
});

@azure/arm-authorization

Provides a generated client for the Azure AuthorizationManagementClient API.

Downloads / mo
1.3M
Stars
2.3K
Last release
9.0.0
License
MIT
$ npm install @azure/arm-authorization @azure/identity
import { AuthorizationManagementClient } from '@azure/arm-authorization';
import { DefaultAzureCredential } from '@azure/identity';

const subscriptionId = '00000000-0000-0000-0000-000000000000';
const client = new AuthorizationManagementClient(new DefaultAzureCredential(), subscriptionId);
for await (const permission of client.permissions.listForResourceGroup('example-rg')) {
  console.log(permission);
}

Enforces authorization through configurable access-control models and policy rules.

Downloads / mo
980.6K
Stars
2.9K
Last release
5.51.1
License
Apache-2.0

Strengths

  • Supports inherited roles. Grant permissions through roles that inherit other roles.
  • Evaluates request-object attributes. Compare request-object fields in an access-control model.

Limitations

  • File policies need explicit saves. Call savePolicy after changing policies stored with the built-in file adapter.
  • Persistence depends on the adapter. Choose an adapter with the storage and update operations the application needs.

Quickstart

From README.md
$ npm install casbin
import { newEnforcer, newModelFromString } from 'casbin';

const model = newModelFromString(`[request_definition]
r = sub, obj, act

[policy_definition]
p = sub, obj, act

[policy_effect]
e = some(where (p.eft == allow))

[matchers]
m = r.sub == p.sub && r.obj == p.obj && r.act == p.act`);
const enforcer = await newEnforcer(model);
await enforcer.addPolicy('alice', 'data1', 'read');
const allowed = await enforcer.enforce('alice', 'data1', 'read');

Casbin examples

From open-source projects on GitHub

FAQ

Role-based access control (RBAC) grants permissions through roles. Relationship-based access control (ReBAC) grants them through a stored relation between a user and an object, such as a viewer of one document. OpenFGA and Authzed check those relations in a separate service.

Both clients send checks to a separate service that stores the relationship data. The OpenFGA SDK calls an OpenFGA API and store, while the Authzed client reaches SpiceDB or Authzed over gRPC.

CASL checks actions, subjects, fields, and object conditions defined in JavaScript. Casbin enforces a configurable access-control model, such as ACL, RBAC, or ABAC, against stored policy rules.

After checking a subject type, check permissions again on the actual object.

Fields can restrict an action to selected subject attributes.

Its built-in file adapter loads and saves policy files. The file adapter stores policies as CSV files and does not support AutoSave.

For coding agents

Found your authorization library? Help your agent use it.

Connect Exa so your coding agent can find the library’s documentation, check its API, and look up implementations while you build.

Run in your terminal

claude plugin install exa@claude-plugins-official