百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
C

cli

> 安全
开源

一个跨平台的 CLI,用于与 OpenFGA 服务器进行交互

100 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

一个跨平台的 CLI,用于与 OpenFGA 服务器进行交互

OpenFGA CLI

A cross-platform CLI to interact with an OpenFGA server

Table of Contents

  • About OpenFGA
  • Resources
  • Installation
  • Building from Source
  • Usage
    • Configuration
    • Custom Headers
    • Commands
      • Stores
        • List All Stores
        • Create a Store
        • Import a Store
        • Export a Store
        • Get a Store
        • Delete a Store
      • Authorization Models
        • Read Authorization Models
        • Write Authorization Model
        • Read a Single Authorization Model
        • Read the Latest Authorization Model
        • Validate an Authorization Model
        • Run Tests on an Authorization Model
        • Transform an Authorization Model
      • Relationship Tuples
        • Read Relationship Tuple Changes (Watch)
        • Read Relationship Tuples
        • Write Relationship Tuples
        • Delete Relationship Tuples
      • Relationship Queries
        • Check
        • Expand
        • List Objects
        • List Relations
        • List Users
      • Mapping
        • Validate a Mapping File
        • Run Embedded Tests
        • Scaffold a Mapping File
        • Evaluate Against JSON Input
  • Contributing
  • License

About

OpenFGA is an open source Fine-Grained Authorization solution inspired by Google's Zanzibar paper. It was created by the FGA team at Auth0/Okta based on Auth0 Fine-Grained Authorization (FGA), available under a permissive license (Apache-2) and welcomes community contributions.

OpenFGA is designed to make it easy for application builders to model their permission layer, and to add and integrate fine-grained authorization into their applications. OpenFGA’s design is optimized for reliability and low latency at a high scale.

Resources

  • OpenFGA Documentation
  • OpenFGA API Documentation
  • Zanzibar Academy
  • Google's Zanzibar Paper (2019)

Installation

Brew

bash
brew install openfga/tap/fga

Linux (deb, rpm and apk) packages

Download the .deb, .rpm or .apk packages from the releases page.

Debian:

bash
sudo apt install ./fga__linux_.deb

Fedora:

bash
sudo dnf install ./fga__linux_.rpm

Alpine Linux:

bash
sudo apk add --allow-untrusted ./fga__linux_.apk

Windows

via Scoop

bash
scoop install openfga

Docker

bash
docker pull openfga/cli; docker run -it openfga/cli

The Docker image is multi-platform and includes the system CA certificates needed for endpoints that use publicly trusted certificate authorities. Private or internal CAs still need to be provided by the user.

Go

bash
go install github.com/openfga/cli/cmd/fga@latest

Manually

Download the pre-compiled binaries from the releases page.

Building from Source

Make sure you have Go 1.25 or later installed. See the Go downloads page.

  1. Clone the repo to a local directory, and navigate to that directory:

    bash
    git clone https://github.com/openfga/cli.git && cd cli
  2. Then use the build command:

    bash
    go build -o ./dist/fga ./cmd/fga/main.go

    or if you have make installed, just run:

    bash
    make build
  3. Run the OpenFGA CLI with:

    bash
    ./dist/fga

Usage

Configuration

For any command that interacts with an OpenFGA server, these configuration values can be passed (where applicable)

Name Flag CLI ~/.fga.yaml
API Url --api-url FGA_API_URL api-url
Shared Secret --api-token FGA_API_TOKEN api-token
Client ID --client-id FGA_CLIENT_ID client-id
Client Secret --client-secret FGA_CLIENT_SECRET client-secret
Scopes --api-scopes FGA_API_SCOPES api-scopes
Token Issuer --api-token-issuer FGA_API_TOKEN_ISSUER api-token-issuer
Token Audience --api-audience FGA_API_AUDIENCE api-audience
Store ID --store-id FGA_STORE_ID store-id
Authorization Model ID --model-id FGA_MODEL_ID model-id
Custom Headers --custom-headers FGA_CUSTOM_HEADERS custom-headers

If you are authenticating with a shared secret, you should specify the API Token value. If you are authenticating using OAuth, you should specify the Client ID, Client Secret, API Audience and Token Issuer. For example:

# Note: This example is for Auth0 FGA
api-url: https://api.us1.fga.dev
client-id: 4Zb..UYjaHreLKOJuU8
client-secret: J3...2pBwiauD
api-audience: https://api.us1.fga.dev/
api-token-issuer: auth.fga.dev
store-id: 01H0H015178Y2V4CX10C2KGHF4

Custom Headers

You can add custom HTTP headers to all requests sent to the API using the --custom-headers flag. Headers are specified in : format, and the flag can be repeated to add multiple headers.

Flag
bash
--custom-headers "Header-Name: header-value"
Example
bash
fga store list --custom-headers "X-Custom-Header: value1" --custom-headers "X-Request-ID: abc123"
Configuration

Custom headers can also be configured via the CLI environment variable or the configuration file:

Name Flag CLI ~/.fga.yaml
Custom Headers --custom-headers FGA_CUSTOM_HEADERS custom-headers

Example ~/.fga.yaml:

yaml
api-url: https://api.fga.example
store-id: 01H0H015178Y2V4CX10C2KGHF4
custom-headers:
  - "X-Custom-Header: value1"
  - "X-Request-ID: abc123"

Commands

Stores

Description command parameters example
Create a Store create --name fga store create --name="FGA Demo Store"
Import a Store import --file fga store import --file store.fga.yaml
Export a Store export --store-id fga store export --store-id=01H0H015178Y2V4CX10C2KGHF4
List Stores list --name fga store list --name="FGA Demo Store"
Get a Store get --store-id fga store get --store-id=01H0H015178Y2V4CX10C2KGHF4
Delete a Store delete --store-id fga store delete --store-id=01H0H015178Y2V4CX10C2KGHF4
Create Store
Command

fga store create

Parameters
  • --name: Name of the store to be created. If the model parameter is specified, the model file name will be used as the default store name.
  • --model: File with the authorization model. Can be in JSON, OpenFGA format, or fga.mod file (optional).
  • --format : Authorization model input format. Can be "fga", "json", or "modular" (optional, defaults to the model file extension if present).
Example

fga store create --name "FGA Demo Store"

Response
json
{
    "id": "01H0H015178Y2V4CX10C2KGHF4",
    "name": "FGA Demo Store",
    "created_at": "2023-05-19T16:10:07.637585677Z",
    "updated_at": "2023-05-19T16:10:07.637585677Z"
}

fga store create --model Model.fga

Response
json
{
  "store": {
    "id":"01H6H9CNQRP2TVCFR7899XGNY8",
    "name":"Model",
    "created_at":"2023-07-29T16:58:28.984402Z",
    "updated_at":"2023-07-29T16:58:28.984402Z"
  },
  "model": {
    "authorization_model_id":"01H6H9CNQV36Y9WS1RJGRN8D06"
  }
}

To automatically set the created store id as an environment variable that will then be used by the CLI, you can use the following command:

bash
export FGA_STORE_ID=$(fga store create --model model.fga | jq -r .store.id)
Import Store
Command

fga store import

Parameters
  • --file: File containing the store. See Store File Format for detailed documentation.
  • --store-id: Specifies the store id to import into
  • --max-tuples-per-write: Max tuples to send in a single write (optional, default=1)
  • --max-parallel-requests: Max requests to send in parallel (optional, default=4)
  • --allow-external-files: Allow model_file, tuple_file and tuple_files references in the store file to resolve outside the store file's directory (optional, default=false). Only enable this for store files you trust.
Example

fga store import --file model.fga.yaml

Response
json
{}
Export Store
Command

fga store export

Parameters
  • --store-id: Specifies the store to export
  • --output-file: The file to output the store to (optional, writes to the terminal if omitted)
  • --model-id: Specifies the model to export (optional, exports the latest model if omitted)
  • --max-tuples: Specifies the max number of tuples to include in the output (optional, defaults to 100)
Example

fga store export --store-id=01H0H015178Y2V4CX10C2KGHF4

Response
…

If using output-file, the response will be written to the specified file on disk. If the desired file already exists, you will be prompted to overwrite the file.

List Stores
Command

fga store list

Parameters
  • --max-pages: Max number of pages to retrieve (default: 20)
  • --name: Filter stores by exact name (substrings and regexes are not supported)
Example

fga store list

fga store list --name="FGA Demo Store"

Response
json
{
  "stores": [{
    "id": "..",
    "name": "..",
    "created_at": "",
    "updated_at": "",
    "deleted_at": ""
  }, { .. }]
}
Get Store
Command

fga store get

Parameters
  • --store-id: Specifies the store id to get
Example

fga store get --store-id=01H0H015178Y2V4CX10C2KGHF4

Response
json
{
    "id": "01H0H015178Y2V4CX10C2KGHF4",
    "name": "FGA Demo Store",
    "created_at": "2023-05-19T16:10:07.637585677Z",
    "updated_at": "2023-05-19T16:10:07.637585677Z"
}
Delete Store
Command

fga store delete

Parameters
  • --store-id: Specifies the store id to delete
Example

fga store delete --store-id=01H0H015178Y2V4CX10C2KGHF4

Response
json
{}

Authorization Models

  • model

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Goaccess-controlclifgafine-grained-authorization

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月18日
分类安全
定价开源

> 相关工具

O
OWASP ZAP
开源 Web 应用安全扫描器
O
owasp-wstg-tracker
Simple web app to track OWASP WSTG security testing progress
H
homebridge-mi-gateway-security
XiaoMi Gateway Security plugin for HomeBridge.