mcpField
A
auth0-cli

auth0-cli

github.com/auth0セキュリティ55408 回インストール1 日前に更新
リポジトリ

auth0-cli について

auth0-cli は、開発者や運用担当者向けに Auth0 テナントをコマンドラインで管理するツールです。アプリ、ユーザー、アクセス制御、ログ監視、設定のエクスポートを扱い、スクリプト向けの機械可読出力も備えています。

主な機能

  1. 01アプリ、API、ユーザーの管理
  2. 02ロールと組織の設定
  3. 03認証 Actions の作成とデプロイ
  4. 04テナントログの確認と転送
  5. 05設定の Terraform エクスポート
  6. 06JSON と CSV の出力

活用シーン

  1. 01Auth0 アプリと API のセットアップ
  2. 02ユーザー検索や一括インポート
  3. 03テナントログでのログイン失敗の調査
  4. 04テナント設定の Terraform 生成

インストール

コマンドをコピーしてターミナルで実行します。

$npx skills add https://github.com/auth0/agent-skills --skill auth0-cli

インストール後、Claude Code で/auth0-cliを入力して読み込まれたか確認します。

同梱ファイルreferences/cli.mdtests/evals.json

詳細

Auth0 CLI — コマンドリファレンス

Auth0 CLI(auth0)を使用すると、ターミナルからテナントを管理できます。Homebrew(brew install auth0/auth0-cli/auth0)でインストールしてください。フラグの定義と使用例については、CLI リファレンス全文を参照してください。


はじめる前に:認証

auth0 login                          # interactive device-code login
auth0 login --scopes "read:client_grants"  # request extra scopes if 403
auth0 login --domain <tenant>.auth0.com --client-id <id> --client-secret "$AUTH0_CLIENT_SECRET"  # CI/CD

JWT を使用したマシンログイン、テナント管理、ログアウトについては、認証の詳細を参照してください。


クイック選択ガイド

作業内容使用するコマンド
新しいプロジェクトをセットアップするauth0 apps create --type spa|regular|m2m|native --json
クライアント ID またはシークレットが必要auth0 apps show <id> -r --json
バックエンド API を登録するauth0 apis create --identifier "https://..." --json
ユーザー ID を調べるauth0 users search --query "email:..." --json
ロール(RBAC)を作成/管理するauth0 roles create / auth0 users roles assign
B2B マルチテナンシーauth0 orgs create
カスタムログインロジックauth0 actions create --trigger post-login --json
ログインページのブランディングauth0 ul update --logo ... --accent ...
ログイン用のカスタムドメインauth0 domains create --domain "auth.myapp.com" --json
ログイン失敗をデバッグするauth0 logs tail --filter "type:f" --json-compact
ログインフローをテストするauth0 test login <client-id>
設定を Terraform としてエクスポートするauth0 terraform generate --output-dir ./terraform
コネクション、許可、フックを管理するauth0 api get <path>
スクリプトでの使用/出力の解析任意のコマンドに --json または --json-compact を追加する
セキュリティを強化するauth0 protection brute-force-protection update --enabled true
ログを外部にルーティングするauth0 logs streams create datadog|http|splunk
ユーザーを一括インポートするauth0 users import --connection-name ... --users '...' --json

コマンドの概要

Apps — アプリケーションの管理

Auth0 アプリケーション(クライアント ID、シークレット、コールバック URL、アプリケーションの種類)を作成または確認します。エイリアス:auth0 clients

auth0 apps create --name "My SPA" --type spa \
  --auth-method None \
  --callbacks "http://localhost:3000" \
  --logout-urls "http://localhost:3000" \
  --origins "http://localhost:3000" --json

auth0 apps list --json-compact
auth0 apps show <client-id> --json
auth0 apps update <client-id> --callbacks "http://localhost:3000,https://myapp.com" --json
auth0 apps delete <client-id> --force

アプリケーションの種類:spa、regular、m2m、native、resource_server

詳細:Apps リファレンス

APIs — API リソースの管理

Auth0 トークンで保護するバックエンド API(リソースサーバー)を登録します。エイリアス:auth0 resource-servers

auth0 apis create --name "My API" --identifier "https://api.myapp.com" \
  --scopes "read:data,write:data" --token-lifetime 3600 --json

auth0 apis list --json-compact
auth0 apis scopes list <api-id> --json

主な違い: apps はトークンを要求するクライアントです。apis はトークンを受け入れるリソースです。

詳細:APIs リファレンス

Users — ユーザーの管理

テナント内のユーザーを作成、検索、確認、インポート、管理します。

auth0 users search --query "email:[email protected]" --json
auth0 users search-by-email [email protected] --json-compact
auth0 users create --connection-name "Username-Password-Authentication" \
  --email "[email protected]" --password "$USER_PASSWORD" --json
auth0 users show <user-id> --json
auth0 users blocks list <email> --json
auth0 users blocks unblock <email>
auth0 users import --connection-name "Username-Password-Authentication" \
  --users '[...]' --upsert --json

詳細:Users リファレンス

Roles — RBAC ロールの管理

ロールを作成し、権限を割り当て、ユーザーにロールを割り当てます。CLI には、ロール操作専用のコマンドが用意されています。

auth0 roles create --name "editor" --description "Can edit content" --json
auth0 roles permissions add <role-id> --api-id <api-id> --permissions "read:data,write:data" --json
auth0 users roles assign <user-id> --roles <role-id>
auth0 users roles show <user-id> --json-compact

詳細:Roles リファレンス

Organizations — B2B マルチテナンシー

B2B SaaS のシナリオ向けに組織を管理します。エイリアス:auth0 orgs

auth0 orgs create --name "acme-corp" --display "Acme Corporation" \
  --logo "https://acme.com/logo.png" --accent "#FF6600" --json
auth0 orgs members list <org-id> --json
auth0 orgs invitations create --org-id <org-id> --invitee-email "[email protected]" \
  --inviter-name "Admin" --client-id <id> --json

詳細:Organizations リファレンス

Actions — サーバーレス認証パイプライン

認証パイプラインのトリガーポイントで実行するサーバーレス関数を作成し、デプロイします。非推奨の Rules に代わるものです。

auth0 actions create --name "Add Claims" --trigger "post-login" \
  --code 'exports.onExecutePostLogin = async (event, api) => { ... }' --json
auth0 actions deploy <action-id>

トリガー:post-login、credentials-exchange、pre-user-registration、post-user-registration、post-change-password、send-phone-message

重要: 変更を反映するには、作成または更新の後に deploy を実行する必要があります。

詳細:Actions リファレンス

Logs — デバッグとモニタリング
auth0 logs tail --filter "type:f" --json-compact    # real-time failed logins
auth0 logs list --filter "type:f" --number 20 --json-compact  # historical

一般的なコード:s(成功)、f(ログイン失敗)、slo(ログアウト)、fs(サイレント認証の失敗)

詳細:Logs リファレンス

Domains — カスタムドメイン
auth0 domains create --domain "auth.myapp.com" --type "auth0_managed_certs" --json
auth0 domains verify <domain-id> --json

詳細:Domains リファレンス

Universal Login — ブランディング
auth0 ul update --accent "#FF6600" --background "#FFFFFF" \
  --logo "https://myapp.com/logo.png" --json

詳細:Universal Login リファレンス

Terraform — IaC としてエクスポート
auth0 terraform generate --output-dir ./terraform --resources "auth0_client,auth0_connection"

詳細:Terraform リファレンス

テスト — ログインフローの検証
auth0 test login <client-id>
auth0 test login <client-id> --audience "https://api.myapp.com" --scopes "openid profile email"

詳細:テストリファレンス

攻撃対策 — セキュリティ強化
auth0 protection brute-force-protection update --enabled true
auth0 protection breached-password-detection update --enabled true
auth0 protection bot-detection update --enabled true

詳細:攻撃対策リファレンス

ログストリーム — 外部へのルーティング
auth0 logs streams create datadog    # interactive setup
auth0 logs streams create http       # custom webhook
auth0 logs streams list --json

対応対象:eventbridge、eventgrid、http、datadog、splunk、sumo

詳細:ログストリームリファレンス

Raw API モード — Management API への直接アクセス

専用のコマンドがない場合は、auth0 api を使って Management API v2 のエンドポイントを直接呼び出します。

auth0 api get connections
auth0 api post client-grants --data '{"client_id":"...","audience":"...","scope":["read:data"]}'
auth0 api get stats/daily -q "from=20240101" -q "to=20240131"

詳細:Raw API リファレンス


出力形式

機械可読な出力には、常に --json または --json-compact を使用してください。3 つのモードは相互に排他的です。

フラグ使用する場面
--json人による確認やデバッグ — インデント付きの整形出力
--json-compactjq へのパイプ渡し、スクリプト、パイプライン — 1 行のコンパクトな出力
--csvスプレッドシートや表形式でのエクスポート
auth0 apps list --json-compact | jq '.[] | {client_id, name}'
auth0 users show <user-id> --json-compact | jq '{id: .user_id, email: .email}'
auth0 roles list --json-compact | jq '.[].name'

詳細:出力形式リファレンス


リファレンスドキュメント

すべてのフラグ、例、使用パターンを網羅した CLI リファレンス:


関連スキル

  • auth0-quickstart — Auth0 の初期セットアップ、フレームワークの検出
  • auth0-migration — 他の認証プロバイダーからの移行
  • auth0-mfa — 多要素認証の設定

参考資料

コメント