8000 Initial CLI docs by gemanor · Pull Request #566 · permitio/docs · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Initial CLI docs #566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions docs/overview/access-requests-and-approvals.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 9
title: Access Requests & Approvals
sidebar_position: 11
title: Access Requests and Approvals
description: Learn how to implement access request workflows and approval processes.
---

In this tutorial, you will learn how to integrate an access request and approval system into your app using Permit.io. We'll
Expand Down
5 changes: 3 additions & 2 deletions docs/overview/advanced-authorization-queries.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 8
sidebar_position: 10
title: Advanced Authorization Queries
description: Learn advanced techniques for querying and filtering authorization data.
---

Authorization plays a crucial role in managing secure access to your systems, and advanced queries can make this process more
Expand Down Expand Up @@ -118,7 +119,7 @@ permission. Today, we use advanced databases and APIs, but the goal remains the
the right things.
:::

<WhatsNext progress={90} customText="No Authorization Query stands a chance now!">
<WhatsNext progress={95} customText="No Authorization Query stands a chance now!">
<h2>What's next? 🎉</h2>
<ul>
<li>Implement bulk permission checks to optimize authorization workflows</li>
Expand Down
5 changes: 3 additions & 2 deletions docs/overview/create-a-rebac-policy.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 6
sidebar_position: 8
title: Create a ReBAC Policy
description: Learn how to create relationship-based access control policies.
---

import WhatsNext from "../../src/components/whats-next/WhatsNext";
Expand Down Expand Up @@ -369,7 +370,7 @@ Now, let's use the provided snippet with out PDP to validate if the user can per
</TimelineStep>
</TimelineWrapper>

<WhatsNext progress={70} customText="You are now a master of ReBAC!">
<WhatsNext progress={80} customText="You are now a master of ReBAC!">
<h2>What's next? 🎉</h2>
<ul>
<li>Assign roles and permissions to users and tenants</li>
Expand Down
7 changes: 4 additions & 3 deletions docs/overview/local-authorization-microservice.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 4
title: Run Local Authorization Microservice
sidebar_position: 6
title: Local Authorization Microservice
description: Set up and run a local Policy Decision Point (PDP) for enhanced performance and security.
timeline: true
---

Expand Down Expand Up @@ -202,7 +203,7 @@ From this walkthrough, you've learned:
A well-configured local PDP can handle **thousands** of authorization decisions per second with **sub-millisecond latency**, making it perfect for high-performance applications. Some of our customers process **millions** of decisions daily with a single PDP instance!
:::

<WhatsNext progress={50} customText="Great job! You're now running local authorization.">
<WhatsNext progress={60} customText="Great job! You're now running local authorization.">
<h2>What's next? 🎉</h2>
<ul>
<li>Create user and resource attributes</li>
Expand Down
3 changes: 2 additions & 1 deletion docs/overview/perform-policy-check-with-cloud-pdp.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 3
sidebar_position: 4
title: Run your First Policy Check
timeline: true
---
Expand Down Expand Up @@ -149,6 +149,7 @@ Companies like Netflix use similar mechanisms to authorize every single request
<WhatsNext progress={40} customText="Amazing! You've mastered cloud policy checks.">
<h2>What's next? 🎉</h2>
<ul>
<li>Manage policies with the <a href="/overview/permit-cli-quickstart">Permit CLI</a> for command-line workflows</li>
<li>Set up a local PDP for enhanced performance</li>
<li>Configure your application for local authorization</li>
<li>Learn about monitoring and debugging your PDP</li>
Expand Down
247 changes: 247 additions & 0 deletions docs/overview/permit-cli-quickstart.mdx
6D40
10000
Original file line number Diff line number Diff line change
@@ -0,0 +1,247 @@
---
sidebar_position: 5
title: Use the Permit CLI
description: Use the Permit CLI to manage, test, and automate your authorization policies from the command line.
---

Now that you've learned how to configure policies and perform authorization checks, let's explore how to manage your authorization system programmatically using the **Permit CLI**. The CLI provides powerful tools for policy management, testing, and automation that complement the web interface and SDKs you've already learned about.

import TimelineStep from "../../src/components/timeline/TimelineStep";
import TimelineWrapper from "../../src/components/timeline/TimelineWrapper";
import WhatsNext from "../../src/components/whats-next/WhatsNext";


## CLI Capabilities & Reference

The **Permit CLI** is an open-source command-line tool that empowers developers to manage, test, and automate fine-grained access control across applications. It provides a comprehensive interface to all of Permit's functionality, including AI-powered policy generation, interactive wizards, policy testing, and local PDP management.

For the complete CLI specification and all available commands, explore the [Permit CLI repository](https://github.com/permitio/permit-cli) and its [full documentation](https://github.com/permitio/permit-cli#full-command-list).

## Prerequisites

Before starting this walkthrough, ensure you have:

- A [Permit.io account](https://app.permit.io) with an active project
- Node.js 16+ installed on your system
- Basic familiarity with command-line tools
- Completed the previous walkthroughs: [Configure your first RBAC policy](/overview/configure-your-first-rbac-policy), [Use the Permit API and SDK](/overview/use-the-permit-api-and-sdk), [Sync your first user](/overview/sync-your-first-user-with-sdk), and [Perform policy checks](/overview/perform-policy-check-with-cloud-pdp)

<TimelineWrapper>
<TimelineStep>

## Install and authenticate with the CLI

The Permit CLI is available as an npm package and provides a command-line interface to all of Permit's functionality.

1. **Install the CLI globally:**

```bash
npm install -g @permitio/cli
```

2. **Verify the installation:**

```bash
permit
```

You should see the following output:
```
Permit CLI is a developer swiss army knife for fine-grained authorization
Run this command with --help for more information

You're not logged in. Run `permit login` to activate all CLI features.
```

3. **Authenticate with your Permit account:**

```bash
permit login
```

This will open your browser to authenticate with Permit.io. After successful authentication, your credentials will be stored locally.

4. **Verify your authentication:**

```bash
permit
```

You should see your account information displayed.

5. **Create an environment:**

```bash
permit env create
```

Now, you can create a new environment so you can start creating policies.

</TimelineStep>
<TimelineStep>

## Create policies using AI

The CLI includes AI-powered policy generation that can create structured RBAC policies from natural language descriptions. This is perfect for quickly prototyping authorization models.

1. **Start the AI policy creation:**

```bash
permit policy create ai
```

2. **Describe your authorization requirements:**

When prompted, describe your application's authorization needs. For example:
```
A document management system with three user types: admins who can do everything, editors who can create and edit documents, and viewers who can only read documents.
```

3. **Review and approve the generated policy:**

The AI will generate a structured policy with resources, roles, and permissions. Review the output and approve it to apply the policy to your environment.

:::tip
The AI policy generator is particularly useful for rapid prototyping and can help you discover authorization patterns you might not have considered.
:::

</TimelineStep>
<TimelineStep>

## Use interactive policy wizards

For more control over policy creation, use the interactive wizard that guides you through each step.

1. **Initialize the policy wizard:**

```bash
permit init
```

This will guide you through creating a complete authorization policy step by step, similar to what you did in the web interface.

2. **Or use the simple policy creator for quick setup:**

```bash
permit policy create simple \
--resources "document:Document@category,status" \
--actions "create:Create Document" "read:Read Document" "update:Update Document" "delete:Delete Document" \
--roles "admin|document:create|document:read|document:update|document:delete" \
--roles "editor|document:create|document:read|document:update" \
--roles "viewer|document:read"
```

This creates a document management system with three roles and their respective permissions, similar to the RBAC policy you configured earlier.

</TimelineStep>
<TimelineStep>

## Sync users and assign roles

Now let's add users and assign them roles using the CLI, building on what you learned about user syncing.

1. **Sync a user with role assignment:**

```bash
permit api sync user \
--key "john@example.com" \
--email "john@example.com" \
--first_name "John" \
--last_name "Doe" \
--roles "admin"
```

2. **Sync another user with a different role:**

```bash
permit api sync user \
--key "jane@example.com" \
--email "jane@example.com" \
--first_name "Jane" \
--last_name "Smith" \
--roles "editor"
```

3. **Verify user assignments:**

```bash
permit api users list
```

This shows all users in your environment, similar to the Directory view in the web interface.

</TimelineStep>
<TimelineStep>

## Perform policy checks from the command line

Now let's test your authorization policies using the CLI, building on your understanding of policy checks.

1. **Run a local PDP:**

```bash
permit pdp run
```

This will start a local PDP instance on port 7766.

2. **Check if John can create a document:**

```bash
permit pdp check \
--user "john@example.com" \
--action "create" \
--resource "document"
```

You should see output indicating whether the user is permitted or denied.

3. **Check if Jane can delete a document:**

```bash
permit pdp check \
--user "jane@example.com" \
--action "delete" \
--resource "document"
```

4. **Check if Jane can read a document:**

```bash
permit pdp check \
--user "jane@example.com" \
--action "read" \
--resource "document"
```

These checks work the same way as the `permit.check()` function you learned about, but from the command line.

</TimelineStep>
</TimelineWrapper>

## What did you learn?

In this walkthrough, you've successfully:

- ✅ Installed and authenticated with the Permit CLI
- ✅ Created authorization policies using AI and interactive wizards
- ✅ Synced users and assigned appropriate roles from the command line
- ✅ Performed policy checks to verify your authorization rules
- ✅ Tested your policies with audit replay and end-to-end tests
- ✅ Run a local PDP for development and testing

The CLI complements the web interface and SDKs you've already learned about, providing a powerful command-line workflow for policy management and automation.

:::tip FUN FACT!
Command-line interfaces have been around since the 1960s! The first CLI was developed for the Compatible Time-Sharing System (CTSS) at MIT, and they've remained essential tools for developers ever since.
:::

<WhatsNext progress={50} customText="Excellent! You've mastered the CLI workflow.">
<h2>What's next? 🎉</h2>
<ul>
<li>Set up a <a href="/overview/local-authorization-microservice">local authorization microservice</a> for production deployment</li>
<li>Configure attribute-based access control (ABAC) policies</li>
<li>Learn about relationship-based access control (ReBAC)</li>
<li>Explore advanced authorization queries and data filtering</li>
</ul>
</WhatsNext>
7 changes: 4 additions & 3 deletions docs/overview/setup-attribute-based-access-control.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 4
title: Create an ABAC Policy
sidebar_position: 7
title: Setup Attribute-Based Access Control
description: Learn how to create and configure ABAC policies using user and resource attributes.
---

Attribute-Based Access Control (ABAC) is a powerful and flexible access control method that uses
Expand Down Expand Up @@ -141,7 +142,7 @@ resources—if the conditions (like their role, location, and task type) align p
policy. This adaptability makes ABAC a popular choice for modern, cloud-based systems
:::

<WhatsNext progress={60} customText="You are now a master of ABAC!">
<WhatsNext progress={70} customText="You are now a master of ABAC!">
Copy link
Preview
Copilot AI Jun 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Progress percentages are updated manually across multiple docs and can easily drift; consider deriving this value dynamically or centralizing it to reduce maintenance overhead.

Suggested change
<WhatsNext progress={70} customText="You are now a master of ABAC!">
const totalSteps = 5; // Total number of steps in the guide
const completedSteps = 5; // Number of steps completed so far
const progress = Math.round((completedSteps / totalSteps) * 100);
<WhatsNext progress={progress} customText="You are now a master of ABAC!">

Copilot uses AI. Check for mistakes.

<h2>What's next? 🎉</h2>
<ul>
<li>Define resource relations and parent-child structures</li>
Expand Down
7 changes: 4 additions & 3 deletions docs/overview/sync-applications-data.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
sidebar_position: 7
title: Sync Data into your App
sidebar_position: 9
title: Sync Applications Data
description: Learn how to sync application data into Permit for advanced authorization scenarios.
---

import userAttributes from "../../static/ui-videos/walkthroughs/sync-data/user-attribute.mp4";
Expand Down Expand Up @@ -235,7 +236,7 @@ Did you know that the concept of data synchronization dates back to the early da
In the 19th century, synchronization was first used to align clocks for railway systems to prevent train collisions.
:::

<WhatsNext progress={80} customText="You can now sync any data into Permit!">
<WhatsNext progress={90} customText="You can now sync any data into Permit!">
<h2>What's next? 🎉</h2>
<ul>
<li>Implement bulk permission checks to optimize authorization workflows</li>
Expand Down
2 changes: 1 addition & 1 deletion docs/overview/sync-your-first-user-with-sdk.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
sidebar_position: 2
sidebar_position: 3
title: Sync your First User
---

Expand Down
Loading
0