# Authentication overview

Source: https://cubibase.com/docs/auth

Also available: [Markdown version](https://cubibase.com/docs/auth.md) · [llms.txt](https://cubibase.com/llms.txt) · [full site content](https://cubibase.com/llms-full.txt)

CubiBase Auth runs on your project host under /auth/v1. Users live in your project’s database, and the access token they receive is the JWT your Data API calls use.

## How it fits together

**Sign-up flow, illustration.** Your app (email + password) → POST /auth/v1/signup → CubiBase Auth (Argon2id hash) → INSERT auth.users → Your database (example_project_db). Response: 201 · session with accessToken, refreshToken, expiresIn: 3600.

Illustration. Sign-up returns the JWT your Data API calls use.

- Users are rows in `auth.users` inside your project’s PostgreSQL database — not a shared directory.
- Passwords are stored only as Argon2id hashes; refresh tokens are stored as hashes too.
- The `accessToken` is an HS256 JWT whose `sub` is the user id. Send it as the bearer token on Data API calls.
- A table with a user column filters rows by that id automatically.

## Sign-in methods

- [Email and password](https://cubibase.com/docs/auth/email-password) Sign up, sign in, and the password rules.
- [Anonymous users](https://cubibase.com/docs/auth/anonymous) Let visitors in first; convert them in place later.
- [Google sign-in](https://cubibase.com/docs/auth/google) OAuth redirect flow and ID-token flow, step by step.
- [Multi-factor (TOTP)](https://cubibase.com/docs/auth/mfa) Authenticator apps, challenges, and required MFA.

Already have an identity provider? Configure the project to verify its RS256 tokens instead — see External identity providers.

## The endpoints at a glance

| Endpoint | Purpose | Bearer token? |
| --- | --- | --- |
| `POST /auth/v1/signup` | Create a user, return a session | No |
| `POST /auth/v1/signup/anonymous` | Create an anonymous session | No |
| `POST /auth/v1/token?grant_type=password` | Sign in | No |
| `POST /auth/v1/token?grant_type=refresh_token` | Refresh a session | No |
| `POST /auth/v1/token?grant_type=mfa` | Complete an MFA challenge | No |
| `POST /auth/v1/token?grant_type=id_token` | Verify a Google ID token | Optional (links) |
| `GET /auth/v1/authorize?provider=google` | Start the Google flow | Optional (links) |
| `GET /auth/v1/callback` | Google redirects back here | No |
| `POST /auth/v1/logout` | Revoke a session | No |
| `GET /auth/v1/user` | Read the signed-in user | Yes |
| `PATCH /auth/v1/user` | Update the user; convert anonymous | Yes |
| `POST /auth/v1/factors` | Enroll a TOTP factor | Yes |
| `POST /auth/v1/factors/verify` | Confirm the first code | Yes |
| `DELETE /auth/v1/factors/{factorId}` | Remove a factor | Yes |

> **note**: Every endpoint requires the `apikey` header with the project’s publishable key — the same key as the Data API. The callback is the exception: Google’s redirect carries no headers, so the single-use state is its security boundary.

## Project settings

All of this is configured per project in Console → Auth: providers, password rules, token lifetimes, MFA, rate limits, the user directory, and sessions.

| Setting | Default |
| --- | --- |
| Signup enabled | On |
| Password sign-in enabled | On |
| Minimum password length | 8 characters |
| Email autoconfirm | On (no confirmation email is sent yet) |
| Access token lifetime | 1 hour |
| Refresh token lifetime | 30 days |
| Anonymous sign-ins | Off |
| Google sign-in | Off |
| MFA | Off (optional or required when on) |
| Signup rate limit | 30 per hour per IP |
| Sign-in rate limit | 30 per minute per IP |

## Additional resources

- [Sessions and tokens](https://cubibase.com/docs/auth/sessions) Rotation, reuse detection, and revocation.
- [External identity providers](https://cubibase.com/docs/auth/external-idp) Bring your own RS256 / JWKS provider.
- [Authentication feature page](https://cubibase.com/features/authentication) The product view of CubiBase Auth.
