# JavaScript authorization libraries

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

| Library | Monthly downloads | Stars | Last release | License |
| --- | --- | --- | --- | --- |
| [@aws-sdk/client-iam](#aws-sdk-client-iam) | 22.6M | 3.7K | Nov 2026 | Apache-2.0 |
| [CASL](#casl) | 10.2M | 7.1K | Nov 2026 | MIT |
| [OpenFGA](#openfga-sdk) | 4.1M | 91 | Nov 2026 | Apache-2.0 |
| [@aws-sdk/client-iot](#aws-sdk-client-iot) | 3.7M | 3.7K | Nov 2026 | Apache-2.0 |
| [@backstage/plugin-permission-node](#backstage-plugin-permission-node) | 3.0M | 34.9K | Nov 2026 | Apache-2.0 |
| [Authzed](#authzed-authzed-node) | 2.1M | 63 | Oct 2025 | Apache-2.0 |
| [@azure/arm-authorization](#azure-arm-authorization) | 1.3M | 2.3K | Apr 2023 | MIT |
| [Casbin](#node-casbin) | 980.6K | 2.9K | Jun 2026 | Apache-2.0 |

Downloads: npm, last thirty days. Stars and releases: GitHub. Amber: no release in over a year.

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

## Capabilities

| Library | In-process evaluator | App-defined objects |
| --- | --- | --- |
| [@aws-sdk/client-iam](#aws-sdk-client-iam) | No | No |
| [CASL](#casl) | Yes | Yes |
| [OpenFGA](#openfga-sdk) | No | Yes |
| [@aws-sdk/client-iot](#aws-sdk-client-iot) | No | No |
| [@backstage/plugin-permission-node](#backstage-plugin-permission-node) | Yes | Yes |
| [Authzed](#authzed-authzed-node) | No | Yes |
| [@azure/arm-authorization](#azure-arm-authorization) | No | No |
| [Casbin](#node-casbin) | Yes | Yes |

## Libraries

### @aws-sdk/client-iam

[GitHub](https://github.com/aws/aws-sdk-js-v3) · [npm](https://www.npmjs.com/package/@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
- Capabilities: [From the @aws-sdk/client-iam docs](https://github.com/aws/aws-sdk-js-v3)

```sh
npm install @aws-sdk/client-iam
```

**awsdocs/aws-doc-sdk-examples** (10.5K stars)

[awsdocs/aws-doc-sdk-examples](https://github.com/awsdocs/aws-doc-sdk-examples) 

```javascript
export const attachRolePolicy = (policyArn, roleName) => {
  const command = new AttachRolePolicyCommand({
    PolicyArn: policyArn,
    RoleName: roleName,
  });

  return client.send(command);
};

```

[javascriptv3/example_code/iam/actions/attach-role-policy.js](https://github.com/awsdocs/aws-doc-sdk-examples/blob/9d44b4c73c4d85f5b953d7063aa81fc3616f3f6c/javascriptv3/example_code/iam/actions/attach-role-policy.js#L16-L23) · [More projects using @aws-sdk/client-iam →](https://dashboard.exa.ai/playground/search?q=%40aws-sdk/client-iam%20GitHub%20projects)

**Quickstart**

```javascript
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/*'],
}));

```

From [SimulatePrincipalPolicyCommand.ts](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-iam/src/commands/SimulatePrincipalPolicyCommand.ts)

### CASL

[GitHub](https://github.com/stalniy/casl) · [npm](https://www.npmjs.com/package/@casl/ability) · [Docs](https://casl.js.org/)

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
- Capabilities: [From the CASL docs](https://casl.js.org/)

**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.

**Watch out for**

- **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.

```sh
npm install @casl/ability
```

**stalniy/casl-examples** (124 stars)

[stalniy/casl-examples](https://github.com/stalniy/casl-examples) 

```javascript
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 });
  });
}

```

[packages/hello-world/src/defineAbility.ts](https://github.com/stalniy/casl-examples/blob/9e03b11ca5c58d339bd9f5d429bfc2c94d28c1f2/packages/hello-world/src/defineAbility.ts#L3-L9) · [More projects using CASL →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20applications%20using%20%40casl/ability%20for%20permission%20rules%20and%20access%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
import { createMongoAbility } from '@casl/ability';

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

```

From [en.md](https://github.com/stalniy/casl/blob/main/packages/casl-ability/src/createMongoAbility.ts)

### OpenFGA

[GitHub](https://github.com/openfga/js-sdk) · [npm](https://www.npmjs.com/package/@openfga/sdk)

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
- Capabilities: [From the OpenFGA docs](https://www.npmjs.com/package/@openfga/sdk)

**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.

**Watch out for**

- **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.

```sh
npm install @openfga/sdk
```

**Quickstart**

```javascript
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",
});

```

From [README.md](https://github.com/openfga/js-sdk/blob/main/README.md) · [Find projects using OpenFGA →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20applications%20using%20%40openfga/sdk%20for%20permission%20rules%20and%20access%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

### @aws-sdk/client-iot

[GitHub](https://github.com/aws/aws-sdk-js-v3) · [npm](https://www.npmjs.com/package/@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
- Capabilities: [From the @aws-sdk/client-iot docs](https://github.com/aws/aws-sdk-js-v3)

```sh
npm install @aws-sdk/client-iot
```

**Quickstart**

```javascript
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'],
  }],
}));

```

From [TestAuthorizationCommand.ts](https://github.com/aws/aws-sdk-js-v3/blob/main/clients/client-iot/src/commands/TestAuthorizationCommand.ts) · [Find projects using @aws-sdk/client-iot →](https://dashboard.exa.ai/playground/search?q=%40aws-sdk/client-iot%20GitHub%20projects)

### @backstage/plugin-permission-node

[GitHub](https://github.com/backstage/backstage) · [npm](https://www.npmjs.com/package/@backstage/plugin-permission-node) · [Docs](https://backstage.io/)

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
- Capabilities: [From the @backstage/plugin-permission-node docs](https://backstage.io/)

```sh
npm install @backstage/plugin-permission-node @backstage/plugin-permission-common
```

**Quickstart**

```javascript
import { createConditionAuthorizer } from '@backstage/plugin-permission-node';
import { AuthorizeResult } from '@backstage/plugin-permission-common';

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

```

From [createPermissionIntegrationRouter.ts](https://github.com/backstage/backstage/blob/master/plugins/permission-node/src/integration/createPermissionIntegrationRouter.ts) · [Find projects using @backstage/plugin-permission-node →](https://dashboard.exa.ai/playground/search?q=%40backstage/plugin-permission-node%20GitHub%20projects)

### Authzed

[GitHub](https://github.com/authzed/authzed-node) · [npm](https://www.npmjs.com/package/@authzed/authzed-node) · [Docs](https://authzed.com/docs/reference/api)

Connects Node.js applications to the Authzed permission service.

- Downloads / mo: 2.1M
- Stars: 63
- Last release: 1.6.1
- License: Apache-2.0
- Capabilities: [From the Authzed docs](https://authzed.com/docs/reference/api)

```sh
npm i @authzed/authzed-node
```

**Quickstart**

```javascript
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);
});

```

From [README.md](https://github.com/authzed/authzed-node/blob/main/README.md) · [Find projects using Authzed →](https://dashboard.exa.ai/playground/search?q=%40authzed/authzed-node%20GitHub%20projects)

### @azure/arm-authorization

[GitHub](https://github.com/Azure/azure-sdk-for-js) · [npm](https://www.npmjs.com/package/@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
- Capabilities: [From the @azure/arm-authorization docs](https://github.com/Azure/azure-sdk-for-js)

```sh
npm install @azure/arm-authorization @azure/identity
```

**Quickstart**

```javascript
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);
}

```

From [arm-authorization.api.md](https://github.com/Azure/azure-sdk-for-js/blob/f59427daa5a2acb87716e4d43dd8fd8bb4b95012/sdk/authorization/arm-authorization/review/arm-authorization.api.md) · [Find projects using @azure/arm-authorization →](https://dashboard.exa.ai/playground/search?q=%40azure/arm-authorization%20GitHub%20projects)

### Casbin

[GitHub](https://github.com/apache/casbin-node-casbin) · [npm](https://www.npmjs.com/package/casbin) · [Docs](https://casbin.org)

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
- Capabilities: [From the Casbin docs](https://casbin.org)

**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.

**Watch out for**

- **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.

```sh
npm install casbin
```

**backstage/community-plugins** (430 stars)

[backstage/community-plugins](https://github.com/backstage/community-plugins) 

```javascript
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);
}

```

[workspaces/rbac/plugins/rbac-backend/src/service/enforcer-delegate.ts](https://github.com/backstage/community-plugins/blob/7086774b8d6542e7f9ce963c3297eb0923988568/workspaces/rbac/plugins/rbac-backend/src/service/enforcer-delegate.ts#L674-L714) · [More projects using Casbin →](https://dashboard.exa.ai/playground/search?q=JavaScript%20TypeScript%20applications%20using%20casbin%20for%20permission%20rules%20and%20access%20checks&filters=%7B%22type%22%3A%20%22auto%22%2C%20%22numResults%22%3A%2010%2C%20%22includeDomains%22%3A%20%5B%22github.com%22%5D%7D)

**Quickstart**

```javascript
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');

```

From [README.md](https://github.com/apache/casbin-node-casbin/blob/master/examples/basic_model.conf)

## FAQ

### ReBAC vs RBAC: what is the difference?

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](#openfga-sdk) and [Authzed](#authzed-authzed-node) check those relations in a separate service.

### OpenFGA vs SpiceDB: how do the clients differ?

Both clients send checks to a separate service that stores the relationship data. The [OpenFGA](#openfga-sdk) SDK calls an OpenFGA API and store, while the [Authzed](#authzed-authzed-node) client reaches SpiceDB or Authzed over gRPC.

### CASL vs Casbin: what is the difference?

[CASL](#casl) checks actions, subjects, fields, and object conditions defined in JavaScript. [Casbin](#node-casbin) enforces a configurable access-control model, such as ACL, RBAC, or ABAC, against stored policy rules.

### Does a successful CASL type check authorize every object?

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

### Can CASL restrict which fields a user changes?

Fields can restrict an action to selected subject attributes.

### Does Casbin write policy files?

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

## How this page was built

Data checked Nov 20, 2026.

Reproduce it with the Exa API:

```json
{
  "endpoint": "/search",
  "body": {
    "query": "Best JavaScript authorization libraries CASL Node-Casbin AccessControl OpenFGA SDK code examples",
    "numResults": 5
  }
}
```

Docs: https://exa.ai/docs/reference/search
