![GitHub Repo Cover](https://private-user-images.githubusercontent.com/18458907/291711345-aa4f9df6-980b-4b24-bb2f-d71c0f480971.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk0MjY5NDQsIm5iZiI6MTczOTQyNjY0NCwicGF0aCI6Ii8xODQ1ODkwNy8yOTE3MTEzNDUtYWE0ZjlkZjYtOTgwYi00YjI0LWJiMmYtZDcxYzBmNDgwOTcxLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEzVDA2MDQwNFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWIyNmI4OGM1ZjBlNzg4YzVjNDZmZjA2YjkwNzk1NjU5MDc2NDU2OTg4NzE1NDI2NWM0ZTQxMzdiZTA2NzJiMWEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.3LozS5Iv0gd5G8peC0utO5HQ0fjDY-H0v25tZMYYZ_U)
This is a sample implementation of the Corbado passkeys-first authentication solution using Python with Django. The following packages are being used:
project
: The Django projectproject/settings.py
: The Django settings fileproject/context_processors.py
: The context processor that adds Corbado environment variables to the template contextproject/middleware.py
: The middleware that adds the authenticated user to the request objectproject/urls.py
: The Django project URL configurationproject/templates
: The Django project templatesproject/templates/base.html
: The base template that acts as a layout to all other templatesproject/utils/authentication.py
: Provides utilities for authentication statemain
: Our main applicationmain/models.py
: Defines our custom user modelmain/views.py
: Contains the views for our applicationmain/urls.py
: The URL configuration for our applicationmain/decorators.py
: Decorator to force authentication on API routesmain/mixins.py
: Mixin to force authentication on class-based views
Please follow the steps in Getting started to create and configure a project in the Corbado developer panel.
You need to have Python and pip
installed to run it.
Use the values you obtained in Prerequisites to configure the following variables inside a .env
file you create in the root folder of this project:
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
Run
python -m venv venv
to create a virtual environment.
Then, activate the virtual environment with
source venv/bin/activate
or
venv\Scripts\activate
on Windows.
To install all dependencies, run
pip install -r requirements.txt
Migrate your database by running
python manage.py migrate
Now you can start the server by running
python manage.py runserver 3000
- Community for Developer Support: https://bit.ly/passkeys-community
- Passkeys Debugger: https://www.passkeys-debugger.io/
- Passkey Subreddit: https://www.reddit.com/r/passkey/