This is a sample implementation of the Corbado passkeys-first authentication solution using Svelte and FastAPI. The following packages are being used:
frontend
: Separate directory for the Svelte frontendfrontend/.env.example
: Example file for environment variablesfrontend/src/routes
: Contains all routes used in the frontendfrontend/src/router/index.ts
: Contains the route definitionsfrontend/src/stores/user.svelte.ts
: Global store for user data from Corbado and our own backendbackend
: Separate directory for the FastAPI backendbackend/.env.example
: Example file for environment variablesbackend/app/main.py
: Entry point for the FastAPI appbackend/app/core/config.py
: Configuration file for the Express appbackend/app/utils
: Collection of utility functions, e.g. helper functions for authenticationbackend/app/routes
: Directory configuring the routes for the appbackend/app/db
: Database configuration and queries
Please follow the steps in Getting started to create and configure a project in the Corbado developer panel.
You need to have Node and npm
installed to run it.
Use the values you obtained in Prerequisites to configure the following variables inside a .env
file you create in frontend and backend directories respectively:
The backend needs an api secret to authenticate with the Corbado backend API.
CORBADO_PROJECT_ID=pro-XXX
CORBADO_API_SECRET=corbado1_XXX
CORBADO_FRONTEND_API=https://{$CORBADO_PROJECT_ID}.frontendapi.cloud.corbado.io
CORBADO_BACKEND_API=https://backendapi.cloud.corbado.io
The frontend needs the project ID and the backend base URL.
VITE_CORBADO_PROJECT_ID=pro-XXX
VITE_BACKEND_BASE_URL=http://localhost:3001
On macOS and Linux, run the following command in the root directory
(cd frontend && npm install)
(cd backend && python3 -m venv venv && source venv/bin/activate && pip install -r requirements.txt && alembic upgrade head)
to install all dependencies and initialize the database.
Activating the virtual environment will be different for Windows users.
Finally, you can run the project locally by individually starting up the frontend and backend.
In one terminal session, run the following command in the frontend
directory:
npm run dev
In another terminal session, run the following command in the backend
directory with an activated virtual environment:
fastapi dev --port 3001
If you encounter any issues regarding imports in the backend, make sure to set your python path:
export PYTHONPATH=$(pwd)
- Community for Developer Support: https://bit.ly/passkeys-community
- Passkeys Debugger: https://www.passkeys-debugger.io/
- Passkey Subreddit: https://www.reddit.com/r/passkey/