Use this prompt with your preferred AI assistant (Claude, ChatGPT, etc.) to automatically integrate Civic Auth into your Django project.

How to Use

  1. Copy the prompt below
  2. Paste it into your AI assistant
  3. The assistant will ask for your project details and guide you through the setup
  4. The assistant will fetch the complete documentation and implement the integration for you

Integration Prompt

# Civic Auth Django Integration Prompt

## Prerequisites
Before starting, you need a Civic Auth Client ID:
1. Visit https://auth.civic.com
2. Sign up or log in to your account
3. Create a new application to obtain your Client ID
4. Copy the Client ID for use in this integration

## Task
Add Civic Auth authentication to this Django application.

## Step 1: Fetch the Documentation
Use curl to fetch the Civic Auth Django documentation:

curl https://docs.civic.com/integration/python/django.md

This documentation contains ALL the code examples and instructions needed for the integration. Do NOT use web search or any other tools - only use curl to fetch this specific URL.

## Step 2: Gather Project Information
Ask the user for the following information if not provided:

**Required Information (gather ALL before starting):**
- ✅ Client ID (if not provided, ask user to get it from https://auth.civic.com)
- ✅ Project type (new/existing Django project)
- ✅ Python environment setup (virtual environment, dependencies)
- ✅ Django version and project structure
- ✅ Protected views/URLs that need authentication
- ✅ Existing authentication systems that need replacement
- ✅ Template preferences (using Django templates vs JSON API responses)
- ✅ Django REST Framework usage (if applicable)
- ✅ Deployment environment (local development, production URLs)

**DO NOT proceed with implementation until you have confirmed ALL of the above information.**

If any information is missing, ask specific questions and wait for responses before continuing. This prevents errors and ensures the integration matches the user's exact requirements.

## Step 3: Create Implementation Plan
After fetching the documentation with curl:
1. Analyze the current Django project structure
2. Identify which code examples from the documentation apply
3. Plan the implementation order (settings, middleware, URLs, views)
4. Note any existing authentication code that needs to be modified
5. Determine if templates or API responses are needed
6. Check for Django REST Framework compatibility needs

## Step 4: Implement Civic Auth
Using ONLY the documentation fetched via curl:
1. Follow the Quick Start guide step by step
2. Install the required civic-auth[django] package
3. Configure Django settings with CIVIC_AUTH configuration
4. Add the CivicAuthMiddleware to MIDDLEWARE
5. Include the auth URLs in your URL patterns
6. Create and protect views with @civic_auth_required decorator
7. Set up templates if needed
8. Handle Django REST Framework integration if applicable
9. Adapt all code examples to this project's structure

## Important Notes
- Use ONLY curl to fetch the documentation - no web search tools
- The fetched documentation is the ONLY source of truth for this implementation
- All code examples, configuration options, and setup instructions are in that document
- Pay attention to Django version compatibility and dependency requirements
- Ensure proper virtual environment setup if needed
- The civic_user is available on request.civic_user with attributes like .name, .email, .id, .picture
- Middleware must be added to MIDDLEWARE list in settings.py
- URLs must include get_auth_urls() for authentication routes

## CRITICAL: Information Gathering Requirements
You MUST gather ALL required information from the user before proceeding with ANY implementation steps:

**Required Information (gather ALL before starting):**
- ✅ Client ID (if not provided, stop and ask user to get it from https://auth.civic.com)
- ✅ Project type (new/existing Django project)
- ✅ Python environment details
- ✅ Django version and project structure
- ✅ Protected views that need authentication
- ✅ Existing authentication systems that need replacement
- ✅ Template vs API response preferences
- ✅ Django REST Framework usage
- ✅ Deployment configuration (URLs for redirect_url and post_logout_redirect_url)

**DO NOT proceed with implementation until you have confirmed ALL of the above information with the user.**

If any information is missing, ask specific questions and wait for responses before continuing. This prevents errors and ensures the integration matches the user's exact requirements.

## Next Steps
After completing basic authentication integration:
- Test the authentication flow with /auth/login
- Verify protected views work correctly
- Update URLs for production deployment
- Add additional protected views as needed
- Create templates for better user experience
- Set up Django REST Framework endpoints if needed
Need help? If you encounter any issues during the LLM-assisted integration, you can always fall back to the manual Django integration guide.

What the AI Assistant Will Do

When you use this prompt, the AI assistant will:
  1. Fetch the documentation using curl from the official Civic Auth docs
  2. Analyze your Django project structure and requirements
  3. Install dependencies and configure your Django settings
  4. Set up middleware and authentication URLs
  5. Create protected views with proper user access
  6. Handle templates or API responses based on your needs
  7. Configure Django REST Framework if you’re building APIs
  8. Test the integration to ensure everything works correctly

Supported AI Assistants

This prompt has been tested with:
  • Claude (Anthropic)
  • Cursor (with Claude)
  • ChatGPT (OpenAI)
  • GitHub Copilot Chat
Make sure your AI assistant has the ability to run terminal commands and edit files in your project.