askrobots / dbbasic-object-server
Public
Runs live, versioned Python application objects on one VM, with a suite of apps: projects, notes, tasks, files and more.
exchange_profile.py · 1.2 KB · 26 lines
| 1 | """site_exchange_profile -- this box's public exchange profile. |
| 2 | |
| 3 | Served by the core route GET /.well-known/dbbasic (object_server), which |
| 4 | runs this object when it is installed and answers 404 when it is not. The |
| 5 | profile is what a partner fetches before it trusts us: our domain, company |
| 6 | name, exchange endpoint, the public keys (active and retired, with their key |
| 7 | ids and the vouches that chain a rotation), the document types we accept and |
| 8 | the DRON document version, signed by the active key. Public by design (a |
| 9 | rule grants execute to everyone); it carries no secret. A box with no |
| 10 | identity yet answers 404; one whose private key is missing answers 409 |
| 11 | naming what to do, rather than publishing a profile it cannot sign. |
| 12 | """ |
| 13 | |
| 14 | import object_exchange |
| 15 | import object_exchange_box as box |
| 16 | |
| 17 | |
| 18 | def GET(request): |
| 19 | try: |
| 20 | return box.profile(box.base_dir()) |
| 21 | except box.Refusal as refusal: |
| 22 | answer = refusal.answer() |
| 23 | return {"status": 404 if refusal.code == "not_configured" else answer["status"], |
| 24 | "error": answer["error"], "code": answer["code"]} |
| 25 | except object_exchange.ExchangeUnavailable as exc: |
| 26 | return {"status": 409, "code": "exchange_unavailable", "error": str(exc)} |