Exapedia / Tools / JavaScript authorization libraries 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 CASL OpenFGA @aws-sdk/client-iot @backstage/plugin-permission-node Authzed @azure/arm-authorization Casbin FAQ Popularity @aws-sdk/client-iam has the most monthly downloads in this comparison, at 22.6M . That count covers every IAM operation.
Libraries and code examples 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 Copy
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. $ npm install @casl/ability Copy
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 });
});
}
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. $ npm install @openfga/sdk Copy
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",
});
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 Copy
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'],
}],
}));
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 Copy
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 $ npm i @authzed/authzed-node Copy
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);
});
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 Copy
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. $ npm install casbin Copy
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 async enforce(
entityRef: string,
resourceType: string,
action: string,
roles: string[],
): Promise<boolean> {
const model = newModelFromString(MODEL);
let policies: string[][] = [];
if (roles.length > 0) {
for (const role of roles) {
const filteredPolicy = await this.getFilteredPolicy(
0,
role,
resourceType,
action,
);
policies.push(...filteredPolicy);
}
} else {
const enforcePolicies = await this.getFilteredPolicy(
1,
resourceType,
action,
);
policies = enforcePolicies.filter(
policy =>
policy[0].startsWith('user:') || policy[0].startsWith('group:'),
);
}
const roleManager = this.enforcer.getRoleManager();
const tempEnforcer = new Enforcer();
model.addPolicies('p', 'p', policies);
await tempEnforcer.initWithModelAndAdapter(model);
tempEnforcer.setRoleManager(roleManager);
await tempEnforcer.buildRoleLinks();
return await tempEnforcer.enforce(entityRef, resourceType, action);
}
Show full example 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.
Claude Code Cursor Codex VS Code Devin Devin Desktop Gemini CLI OpenCode
Run in your terminal
claude plugin install exa@claude-plugins-official Copy Add to ~/.cursor/mcp.json
{
"mcpServers": {
"exa": {
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy Open in your browser, then install the Exa plugin
https://chatgpt.com/plugins/exa Copy Add to .vscode/mcp.json
{
"servers": {
"exa": {
"type": "http",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy In Devin, open Customize, then MCPs, and add a custom HTTP server with this URL
https://mcp.exa.ai/mcp Copy Add to ~/.config/devin/mcp_config.json
{
"mcpServers": {
"exa": {
"serverUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to ~/.gemini/settings.json
{
"mcpServers": {
"exa": {
"httpUrl": "https://mcp.exa.ai/mcp"
}
}
} Copy Add to opencode.json
{
"mcp": {
"exa": {
"type": "remote",
"url": "https://mcp.exa.ai/mcp"
}
}
} Copy