-
Notifications
You must be signed in to change notification settings - Fork 8
Add comprehensive GitHub Copilot instructions and MCP configuration for django-descope #320
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
Copilot
wants to merge
8
commits into
main
Choose a base branch
from
copilot/fix-319
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
b3acf64
Initial plan
Copilot c2c3cec
Create comprehensive .github/copilot-instructions.md with validated c…
Copilot f7a785a
Update to use Poetry and add MCP servers configuration
Copilot 87936c1
Update mcp.json
omercnet f3bc27d
Update mcp.json
omercnet 6f075dc
Update mcp.json
omercnet 265bdbc
Update mcp.json
omercnet 402bb41
Resolve merge conflicts with main branch
Copilot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,173 @@ | ||
| # Django Descope Integration Plugin | ||
|
|
||
| Django-descope is a Django plugin that integrates Descope authentication and user management platform with Django applications. The plugin provides middleware, authentication backends, template tags, and views for seamless integration with Descope's authentication flows. | ||
|
|
||
| Always reference these instructions first and fallback to search or bash commands only when you encounter unexpected information that does not match the info here. | ||
|
|
||
| ## Working Effectively | ||
|
|
||
| ### Bootstrap and Setup | ||
| - **Install Python dependencies**: | ||
| ```bash | ||
| poetry install --with dev | ||
| ``` | ||
| - Installation takes ~90 seconds. Uses Poetry for consistent dependency management. | ||
| - Note: django-stubs is only installed on Python >=3.10 due to version constraints. | ||
|
|
||
| - **Set required environment variables**: | ||
| ```bash | ||
| export DESCOPE_PROJECT_ID=P2ZRsmAQw8MKG78knGZ9GXWRqxM5 # Test project ID | ||
| # export DESCOPE_MANAGEMENT_KEY=your_secret_key # Required for full test suite | ||
| ``` | ||
|
|
||
| - **Initialize Django application**: | ||
| ```bash | ||
| poetry run python manage.py migrate # ~0.6 seconds | ||
| poetry run python manage.py check # Validates Django configuration | ||
| ``` | ||
|
|
||
| ### Development Workflow | ||
| - **Run development server**: | ||
| ```bash | ||
| export DESCOPE_PROJECT_ID=P2ZRsmAQw8MKG78knGZ9GXWRqxM5 | ||
| poetry run python manage.py runserver 0.0.0.0:8000 | ||
| ``` | ||
| - Server starts instantly and runs on port 8000 | ||
| - Access demo app at http://localhost:8000/ | ||
| - Admin interface at http://localhost:8000/admin/ | ||
|
|
||
| ### Testing | ||
| - **Run linting** (ALWAYS run before committing): | ||
| ```bash | ||
| poetry run flake8 django_descope/ # ~0.16 seconds | ||
| poetry run black --check django_descope/ # ~0.25 seconds | ||
| poetry run isort --check-only django_descope/ # ~0.12 seconds | ||
| ``` | ||
| - All linting is very fast (<1 second total) | ||
| - CI will fail if linting doesn't pass | ||
|
|
||
| - **Run basic tests**: | ||
| ```bash | ||
| poetry run python manage.py test --exclude-tag=requires-management-key | ||
| ``` | ||
| - Most tests require DESCOPE_MANAGEMENT_KEY (secret from CI) | ||
| - Basic validation tests work without the management key | ||
|
|
||
| - **Run tests via tox** (full test matrix): | ||
| ```bash | ||
| poetry run tox -v # Tests across Python 3.9-3.13 and Django 3.2-5.1 | ||
| ``` | ||
| - **NEVER CANCEL**: Full tox run can take 5-10 minutes. Set timeout to 15+ minutes. | ||
| - Requires both DESCOPE_PROJECT_ID and DESCOPE_MANAGEMENT_KEY environment variables | ||
| - **Note**: May fail due to network connectivity limitations in some environments | ||
|
|
||
| ## Validation Scenarios | ||
| After making changes, always verify: | ||
|
|
||
| 1. **Basic Django functionality**: | ||
| ```bash | ||
| poetry run python manage.py check | ||
| poetry run python manage.py migrate # if you added migrations | ||
| ``` | ||
|
|
||
| 2. **Linting compliance**: | ||
| ```bash | ||
| poetry run black django_descope/ example_app/ | ||
| poetry run isort django_descope/ example_app/ | ||
| poetry run flake8 django_descope/ | ||
| ``` | ||
|
|
||
| 3. **Authentication flow** (manual testing): | ||
| - Start development server | ||
| - Visit http://localhost:8000/ | ||
| - Verify Descope authentication widget loads | ||
| - Test login/logout flow if you have test credentials | ||
|
|
||
| 4. **Admin integration**: | ||
| - Visit http://localhost:8000/admin/ | ||
| - Verify custom Descope admin login template loads | ||
|
|
||
| ## Common Development Tasks | ||
|
|
||
| ### Repository Structure | ||
| ``` | ||
| . | ||
| ├── django_descope/ # Main plugin package | ||
| │ ├── authentication.py # Authentication backend | ||
| │ ├── middleware.py # Descope middleware | ||
| │ ├── views.py # Auth views | ||
| │ ├── templatetags/ # Django template tags | ||
| │ └── templates/ # HTML templates for auth | ||
| ├── example_app/ # Demo/test application | ||
| │ ├── templates/ # Example templates | ||
| │ └── test_admin.py # Integration tests | ||
| ├── manage.py # Django management script | ||
| ├── settings.py # Django settings with Descope config | ||
| ├── pyproject.toml # Poetry configuration | ||
| ├── tox.ini # Test matrix configuration | ||
| └── .github/workflows/ # CI/CD configuration | ||
| ``` | ||
|
|
||
| ### Key Configuration Files | ||
| - **pyproject.toml**: Python dependencies and project metadata | ||
| - **settings.py**: Django settings with DESCOPE_PROJECT_ID configuration | ||
| - **tox.ini**: Test matrix across Python/Django versions | ||
| - **.pre-commit-config.yaml**: Git hooks for linting | ||
| - **.github/workflows/ci.yaml**: GitHub Actions CI configuration | ||
|
|
||
| ### Environment Variables | ||
| ```bash | ||
| # Required for basic functionality | ||
| DESCOPE_PROJECT_ID=P2ZRsmAQw8MKG78knGZ9GXWRqxM5 # Test project | ||
|
|
||
| # Required for full test suite (CI secret) | ||
| DESCOPE_MANAGEMENT_KEY=your_secret_key | ||
|
|
||
| # Optional Django settings | ||
| DEBUG=True | ||
| SECRET_KEY=your_secret_key | ||
| ``` | ||
|
|
||
| ### Dependency Management | ||
| - **Primary**: Use `poetry install --with dev` for dependencies (consistent environments) | ||
| - **Note**: django-stubs requires Python >=3.10, handled via conditional installation | ||
| - **Lock file**: Keep poetry.lock updated with `poetry lock` when changing dependencies | ||
|
|
||
| ### Testing Approach | ||
| - Unit tests in `django_descope/test_store_jwt.py` | ||
| - Integration tests in `example_app/test_admin.py` | ||
| - Most tests require Descope management API access | ||
| - Use test project ID: `P2ZRsmAQw8MKG78knGZ9GXWRqxM5` | ||
| - Full test suite needs management key from CI secrets | ||
|
|
||
| ### CI/CD Integration | ||
| - **GitHub Actions**: `.github/workflows/ci.yaml` | ||
| - **Test matrix**: Python 3.9-3.13 × Django 3.2-5.1 | ||
| - **Required secrets**: DESCOPE_MANAGEMENT_KEY | ||
| - **Pre-commit hooks**: Automatic linting and formatting | ||
| - **Publishing**: Automated PyPI publication on release | ||
|
|
||
| ## Troubleshooting | ||
|
|
||
| ### Common Issues | ||
| 1. **"DESCOPE_PROJECT_ID is required"** - Set the environment variable | ||
| 2. **Poetry dependency conflicts** - Use pip instead of poetry | ||
| 3. **Management key errors in tests** - Tests requiring API access need DESCOPE_MANAGEMENT_KEY | ||
| 4. **Django check failures** - Ensure all required dependencies are installed | ||
| 5. **Pre-commit hooks fail to install** - Network connectivity issues; use linting tools directly instead | ||
| 6. **Tox fails with pip timeout** - Network connectivity limitations may prevent full test matrix execution | ||
|
|
||
| ### Performance Notes | ||
| - **Dependency installation**: ~90 seconds for poetry install --with dev | ||
| - **Django operations**: All under 1 second (migrations: ~0.6s, check: instant, runserver: instant startup) | ||
| - **Linting tools**: All under 1 second (flake8: ~0.16s, black: ~0.25s, isort: ~0.12s) | ||
| - **Basic tests**: Under 1 second but require DESCOPE_MANAGEMENT_KEY for full functionality | ||
| - **Tox full test matrix**: 5-10 minutes when network allows - **NEVER CANCEL** | ||
| - No complex build steps or compilation required | ||
| - Development server starts instantly | ||
|
|
||
| ### File Locations to Check | ||
| - Always check `django_descope/conf.py` when modifying settings | ||
| - Template changes go in `django_descope/templates/admin/` | ||
| - Authentication logic is in `django_descope/authentication.py` | ||
| - Middleware modifications in `django_descope/middleware.py` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| { | ||
| "mcpServers": { | ||
| "memory": { | ||
| "command": "python", | ||
| "args": [ | ||
| "-m", | ||
| "mcp.server.memory" | ||
| ], | ||
| "env": {}, | ||
| "disabled": false | ||
| }, | ||
| "sequentialthinking": { | ||
| "command": "python", | ||
| "args": [ | ||
| "-m", | ||
| "mcp.server.sequentialthinking" | ||
| ], | ||
| "env": {}, | ||
| "disabled": false | ||
| }, | ||
| "filesystem": { | ||
| "command": "python", | ||
| "args": [ | ||
| "-m", | ||
| "mcp.server.filesystem", | ||
| "/home/runner/work/django-descope/django-descope" | ||
omercnet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| "env": {}, | ||
| "disabled": false | ||
| }, | ||
| "sqlite": { | ||
| "command": "python", | ||
| "args": [ | ||
| "-m", | ||
| "mcp.server.sqlite", | ||
| "/home/runner/work/django-descope/django-descope/db.sqlite3" | ||
omercnet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| "env": {}, | ||
| "disabled": false | ||
| }, | ||
| "git": { | ||
| "command": "python", | ||
| "args": [ | ||
| "-m", | ||
| "mcp.server.git", | ||
| "/home/runner/work/django-descope/django-descope" | ||
omercnet marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| ], | ||
| "env": {}, | ||
| "disabled": false | ||
| }, | ||
| "python": { | ||
| "command": "python", | ||
| "args": [ | ||
| "-m", | ||
| "mcp.server.python" | ||
| ], | ||
| "env": {}, | ||
| "disabled": false | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.