auth0-cli について
auth0-cli は、開発者や運用担当者向けに Auth0 テナントをコマンドラインで管理するツールです。アプリ、ユーザー、アクセス制御、ログ監視、設定のエクスポートを扱い、スクリプト向けの機械可読出力も備えています。
主な機能
- 01アプリ、API、ユーザーの管理
- 02ロールと組織の設定
- 03認証 Actions の作成とデプロイ
- 04テナントログの確認と転送
- 05設定の Terraform エクスポート
- 06JSON と CSV の出力
活用シーン
- 01Auth0 アプリと API のセットアップ
- 02ユーザー検索や一括インポート
- 03テナントログでのログイン失敗の調査
- 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
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 を実行する必要があります。
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
Universal Login — ブランディング
auth0 ul update --accent "#FF6600" --background "#FFFFFF" \
--logo "https://myapp.com/logo.png" --json
Terraform — IaC としてエクスポート
auth0 terraform generate --output-dir ./terraform --resources "auth0_client,auth0_connection"
テスト — ログインフローの検証
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"
出力形式
機械可読な出力には、常に --json または --json-compact を使用してください。3 つのモードは相互に排他的です。
| フラグ | 使用する場面 |
|---|---|
--json | 人による確認やデバッグ — インデント付きの整形出力 |
--json-compact | jq へのパイプ渡し、スクリプト、パイプライン — 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 リファレンス:
- セットアップガイド — インストール、認証、CI/CD の設定
- 認証 — ログインモード、テナント管理、スコープ
- アプリ — 作成、一覧表示、表示、更新、削除、セッション転送
- API — 作成、スコープ、トークンの有効期間
- ユーザー — 検索、作成、インポート、ブロック、ロール
- ロール — RBAC の設定、権限管理
- 組織 — B2B、メンバー、招待
- アクション — パイプライントリガー、デプロイワークフロー
- ログ — テール、一覧表示、タイプコード
- ドメイン — カスタムドメイン、検証
- ユニバーサルログイン — ブランディング、テンプレート、プロンプト
- Terraform — IaC のエクスポート
- テスト — ログインフローの検証
- 攻撃対策 — ブルートフォース、侵害、ボットの検出
- ログストリーム — 外部サービスへのルーティング
- Raw API モード — Management API への直接アクセス
- 出力形式 — --json、--json-compact、--csv
- 共通フラグ — --tenant、--no-input、--debug
関連スキル
auth0-quickstart— Auth0 の初期セットアップ、フレームワークの検出auth0-migration— 他の認証プロバイダーからの移行auth0-mfa— 多要素認証の設定