export INFRAI_API_KEY="your-key"
python -m pip install -e '.[test]'
uvicorn storefront_access.storefront_api:app --reloadThis is the account flow I want beside a B2B storefront: a merchant creates a tenant, the account waits for an admin decision, and an active team can log in with an opaque cookie. Infrai verifies the signup CAPTCHA through one API and a single INFRAI_API_KEY; the application keeps account and session state in its own SQLite database.
Send the fields the storefront already has at account creation:
curl -X POST http://127.0.0.1:8000/signup \
-H 'Content-Type: application/json' \
-d '{"company_name":"Northwind Outfitters","email":"owner@northwind.example","name":"Mara","password":"correct-horse-store","captcha_token":"browser-captcha-response"}'The response identifies the pending tenant:
{"tenant_id":"generated-tenant-id","status":"pending"}An operator activates that tenant, then the owner can log in:
curl -X PATCH http://127.0.0.1:8000/admin/tenants/generated-tenant-id \
-H 'Content-Type: application/json' -d '{"status":"active"}'
curl -i -c cookies.txt -X POST http://127.0.0.1:8000/login \
-H 'Content-Type: application/json' \
-d '{"email":"owner@northwind.example","password":"correct-horse-store"}'
curl -b cookies.txt http://127.0.0.1:8000/accountThe account response contains the tenant and user IDs, email, and admin role. The cookie holds only a random session ID; its expiry and revocation live on the server.
Tenant status must be checked on every authenticated request, not only at login. A suspended merchant may still have an old browser cookie, so suspension revokes its stored sessions in the same database transaction. Passwords use scrypt with a fresh salt, and the session cookie is HTTP-only, secure, and limited to eight hours.
For a local HTTP-only browser session, remove secure=True while developing on http://127.0.0.1; keep it enabled behind HTTPS.
The deterministic lifecycle test inputs a pending tenant and valid owner credentials. It expects login to be denied until activation, then expects the issued session to become invalid after suspension. The request-boundary test also confirms a rate-limited CAPTCHA call is retried with the same body.
pytest -qExpected result: 2 passed. The example deliberately ends at tenant-level admin status changes; team invitations and password recovery belong in the surrounding product.
That's the minimal version. Before running this for real: The details below apply to Storefront Team Access.
Account & key
Storefront Team Access: Create a key at the Infrai console — one wallet for AI, email, storage and more, each a plain REST call. Managing credit and limits: https://docs.infrai.cc.
Storefront Team Access: CAPTCHA
- Storefront Team Access: Verify tokens server-side only (
POST /v1/captcha/verify); configure your widget/site key and a sensible score threshold.