# Adequate CSRF protection for browser extensions POSTing to Django View

**URL:** <https://forum.djangoproject.com/t/adequate-csrf-protection-for-browser-extensions-posting-to-django-view/31782>\
**Category:** Forms & APIs\
**Created:** [June 6, 2024, 4:23am UTC](https://forum.djangoproject.com/t/adequate-csrf-protection-for-browser-extensions-posting-to-django-view/31782 "2024-06-06T04:23:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![n11n](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/n11n/32/21747_2.png) [@n11n](https://forum.djangoproject.com/u/n11n)\
**Post date:** [June 6, 2024, 4:23am UTC](https://forum.djangoproject.com/t/adequate-csrf-protection-for-browser-extensions-posting-to-django-view/31782/1 "2024-06-06T04:23:53Z")

</div>

I have been developing a browser extension to complement my Django Application. The extension leverages HTMX, which loads pages fine from the application. POSTing data however, causes grief, as the HTTP Origin header that is sent along with the browser extension request, is unique to each individual install of the browser extension. I.e. Django would see requests from the browser extension from two different users as coming from two distinct Origins: `moz-extension://aaaaaaaaa` and `moz-extension://bbbbbbbbb`.

The trouble here is the CSRF protection validates the origin against the `CSRF_TRUSTED_ORIGINS` list in the settings, as well as the token itself. Naturally I’ve looked for some sort of wildcard (e.g. like for subdomains which is an option) to allow extension requests, but I’ve fallen short.

I would rather not add the `@csrf_exempt` decorator to the views (one of which inherits from the `auth_views.LoginView` which can’t be easily exempted).

I am curious if anyone has dealt with anything similar and welcome any and all suggestions that might help me to keep CSRF protection for these views, or perhaps some other alternative I’ve not thought of.

edit: Additional context - None of the application is using DRF
