Authentication and security
Nostr login, magic links, sessions, CSRF, roles, and logout.
Authentication and security
La Crypta supports Nostr and email login. Both flows end in the same 24-hour browser session and the same membership check per organization.
Sign in with Nostr
NIP-07 signers, NIP-46 connections, and keys deliberately loaded by the user are supported. The recommended flow is:
- Open
/o/{organizationSlug}/login. - Connect the signer.
- Sign a kind
27235NIP-98 event forPOST /api/auth. - Include the organization slug as signed intent.
- Receive a 24-hour,
HttpOnly,SameSite=Laxsession cookie.
The signature binds the exact method, URL, timestamp, and pubkey. The server rejects invalid signatures, another host or method, or a timestamp more than 60 seconds away.
A login signature proves control of a key, but does not grant a role by itself. The role comes from an active membership in the organization.
Sign in by email
The form requests a single-use magic link. The link expires after 15 minutes, does not reveal whether the address exists, and can carry the intended organization. Verification creates or recovers the identity, accepts compatible invitations, and sets the same session cookie.
Browser session
The session JWT is not available to JavaScript: it lives only in the secure cookie. The browser should send credentials: "same-origin". Do not copy cookies or try to persist them in localStorage.
Use POST /api/auth/logout to end the session; it clears the session cookie, CSRF token, and local caches containing personal data.
CSRF for mutations
GET, HEAD, and OPTIONS do not require a CSRF token. For cookie-authenticated POST, PUT, PATCH, or DELETE requests:
- Request
GET /api/auth/csrfwith same-origin credentials. - Keep the response’s
csrfTokenin memory only. - Send the same value in
x-csrf-tokenalong with the CSRF cookie. - Use the same request origin.
The dashboard and playground automate this exchange. A 403 forbidden on a mutation often means an invalid origin or CSRF token; renew it once before asking the user to sign in again.
Organization API keys
Owners can create service credentials under Dashboard → Settings → API Keys. Send them only through this header:
X-API-Key: lcr_live_<prefix>_<secret>The complete secret is displayed once. Store it in a server-side secret manager; never put it in public JavaScript, repositories, URLs, screenshots, or logs. Keys may expire, can be revoked immediately, and are limited to read, create, update, delete, and execute.
Every compatible operation declares x-api-key-permission in OpenAPI. Keys work only on canonical /api/organizations/{organizationSlug}/... paths; they never enable /api/me, memberships, roles, the platform control plane, settings, or integration secrets. A 401 means the key is invalid, expired, or revoked; a 403 means the operation or permission is not enabled.
curl 'https://crm.lacrypta.ar/api/organizations/my-community/events' \
-H 'X-API-Key: lcr_live_<prefix>_<secret>'Organization roles
| Role | Typical scope |
|---|---|
guest | Own profile and resources |
manager | Daily operation of Events, attendees, content, and communications |
admin | Organization settings, members, domains, integrations, and audit |
Authorization is checked on every request against the current membership. Changing, suspending, or revoking a membership removes access without waiting for the session to expire.
Good practices
- Prefer an extension or bunker; never paste an
nsecinto documentation, logs, or support tickets. - Sign only requests whose host, method, and path you recognize.
- Use a test organization for write operations.
- Log out on shared devices.
- Treat ticket codes, confirmation tokens, and magic links as bearer secrets.