Keep client secrets in add-on storage; host only verifies and serves the local API.
This commit is contained in:
@@ -1,41 +1,11 @@
|
||||
#!/usr/bin/env python3
|
||||
"""CLI fallback for client secrets. Prefer the add-on Manage clients page."""
|
||||
"""Secrets are issued in the add-on UI, not from this script."""
|
||||
from __future__ import annotations
|
||||
|
||||
import argparse
|
||||
import json
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
ROOT = Path(__file__).resolve().parents[1]
|
||||
sys.path.insert(0, str(ROOT))
|
||||
|
||||
from fab_auth import CLIENTS_PATH, create_client, list_clients, revoke_client # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
parser = argparse.ArgumentParser(description="Manage Firefox Agent Bridge clients (CLI)")
|
||||
sub = parser.add_subparsers(dest="cmd", required=True)
|
||||
add = sub.add_parser("add", help="generate a secret (printed once)")
|
||||
add.add_argument("--name", required=True)
|
||||
sub.add_parser("list")
|
||||
drop = sub.add_parser("revoke")
|
||||
drop.add_argument("name_or_id")
|
||||
ns = parser.parse_args()
|
||||
if ns.cmd == "add":
|
||||
created = create_client(ns.name)
|
||||
print(created["token"])
|
||||
print(
|
||||
f"id={created['id']} name={created['name']} — store that token in FAB_TOKEN; it will not be shown again.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
return 0
|
||||
if ns.cmd == "list":
|
||||
print(json.dumps({"store": str(CLIENTS_PATH), "clients": list_clients()}, indent=2))
|
||||
return 0
|
||||
print(json.dumps({"revoked": revoke_client(ns.name_or_id)}))
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
print(
|
||||
"Generate and revoke clients in Firefox: Bookmarks API toolbar → Manage clients.",
|
||||
file=sys.stderr,
|
||||
)
|
||||
raise SystemExit(2)
|
||||
|
||||
Reference in New Issue
Block a user