Skip to content

Latest commit

 

History

History
98 lines (67 loc) · 2.81 KB

README.md

File metadata and controls

98 lines (67 loc) · 2.81 KB
GitHub Repo Cover

Python Django Passkeys Example Application

This is a sample implementation of the Corbado passkeys-first authentication solution using Python with Django. The following packages are being used:

File structure

  • project: The Django project
  • project/settings.py: The Django settings file
  • project/context_processors.py: The context processor that adds Corbado environment variables to the template context
  • project/middleware.py: The middleware that adds the authenticated user to the request object
  • project/urls.py: The Django project URL configuration
  • project/templates: The Django project templates
  • project/templates/base.html: The base template that acts as a layout to all other templates
  • project/utils/authentication.py: Provides utilities for authentication state
  • main: Our main application
  • main/models.py: Defines our custom user model
  • main/views.py: Contains the views for our application
  • main/urls.py: The URL configuration for our application
  • main/decorators.py: Decorator to force authentication on API routes
  • main/mixins.py: Mixin to force authentication on class-based views

Setup

Prerequisites

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.

Configure environment variables

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

Usage

Run the project locally

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

Passkeys support