Skip to content

ephes/django-indieweb

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

359 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

django-indieweb

https://img.shields.io/readthedocs/django-indieweb?style=for-the-badge https://img.shields.io/pypi/v/django-indieweb.svg?style=for-the-badge prek

A Django application that provides IndieAuth, Micropub, Webmention, and WebSub support for IndieWeb integration

Documentation

The full documentation is at https://django-indieweb.readthedocs.io/.

Features

  • IndieAuth authentication endpoint
  • IndieAuth token endpoint
  • Micropub endpoint with content creation, source query, update, delete, undelete, and media upload support
  • Webmention sending and receiving
  • WebSub publisher helpers for topic discovery links and hub notifications
  • Minimal WebSub subscriber callback support with lease tracking and delivery hooks
  • Pluggable content handler system for Micropub
  • Pluggable interfaces for Webmention URL resolution and spam checking
  • Support for both form-encoded and JSON Micropub requests
  • Microformats2 parsing for rich webmention content
  • Micropub query endpoints (config with media-endpoint discovery, syndicate-to, source)
  • Django integration

Installation

Install django-indieweb using pip:

pip install django-indieweb

Or with uv:

uv pip install django-indieweb

Quick Start

  1. Add "indieweb" to your INSTALLED_APPS setting:

    INSTALLED_APPS = [
        ...
        'indieweb',
    ]
    
  2. Include the indieweb URLconf in your project urls.py:

    path('indieweb/', include('indieweb.urls')),
    
  3. Run migrations:

    python manage.py migrate
    
  4. Visit the IndieWeb endpoints at:

    • /indieweb/auth/ - Authentication endpoint
    • /indieweb/token/ - Token endpoint
    • /indieweb/micropub/ - Micropub endpoint
    • /indieweb/media/ - Micropub media endpoint
    • /indieweb/webmention/ - Webmention endpoint
  5. To use Micropub for content creation and editing, create a custom content handler:

    from indieweb.handlers import MicropubContentHandler, MicropubEntry
    
    class MyContentHandler(MicropubContentHandler):
        def create_entry(self, properties, user):
            # Create your content here
            post = MyBlogPost.objects.create(
                author=user,
                content=properties.get('content', [''])[0]
            )
            return MicropubEntry(
                url=post.get_absolute_url(),
                properties=properties
            )
        # ... implement other methods
    

    Then configure it in settings:

    INDIEWEB_MICROPUB_HANDLER = 'myapp.handlers.MyContentHandler'
    

Production Deployment

The bundled defaults favour protocol compatibility (PKCE optional, me not bound to the logged-in user, rate limits disabled). For an internet-facing IndieAuth/Micropub deployment, see the Production hardening section of the configuration guide for a copyable settings snippet: https://django-indieweb.readthedocs.io/en/latest/configuration.html#production-hardening

Adapter Responsibilities

Micropub handlers are host-owned authorization boundaries. After django-indieweb authenticates the bearer token and checks the requested scope, your MicropubContentHandler must verify that the authenticated user is allowed to create, update, delete, undelete, read source content, list content or media, and manage media for the submitted URL or storage object. The bundled InMemoryMicropubHandler is an unsafe development/testing example only; it keeps entries in process memory and performs no ownership checks.

Development

Setting up development environment:

git clone https://github.com/ephes/django-indieweb.git
cd django-indieweb
uv sync

Handy Just commands (install just first)

just install      # sync dependencies via uv
just test         # run the pytest suite
just typecheck    # run mypy
just test-one path/to/test.py::TestCase::test_method

Running Tests

Run the test suite with coverage and the configured coverage gate:

uv run pytest

Generate an HTML coverage report:

uv run pytest --cov-report=html
open htmlcov/index.html

Run tests for the supported Python/Django matrix using tox:

tox

The supported tox matrix covers Django 5.2 LTS on Python 3.10 through 3.14 and Django 6.0 on Python 3.12 through 3.14.

Run tests once with Django migrations enabled using tox:

tox -e py313-django52-migrations

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

BSD License

About

Just some of the indieweb endpoints for Django

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages