Postgres audit database via triggers
This app sets up a postgres audit database via triggers. See https://wiki.postgresql.org/wiki/Audit_trigger_91plus and https://github.com/2ndQuadrant/audit-trigger/ for more information.
Installation
pip install postgres_audit_triggers
Usage
- Add the
postgres_audit_triggersapp toINSTALLED_APPSbefore any apps that will be audited:
# settings.py
INSTALLED_APPS = {
'django.contrib.postgres',
'postgres_audit_triggers',
...
}
- Install the
postgres_audit_triggersmiddleware:
# settings.py
MIDDLEWARE = [
...
'postgres_audit_triggers.middleware.AuditMiddleware',
]
This middleware will add metadata to the audit row. To send metadata, the client must send a
Postgres-Audit-Triggers-Meta header in the request to your Django view. The data within
that header must be JSON serializable to a python dictionary.
-
Run migrations:
python manage.py migrate postgres_audit_triggers -
Add
audit_trigger = Trueto the Model Meta options of the models that will be audited:
# models.py
class MyAuditedModel(models.Model):
...
class Meta:
audit_trigger = True
...
- Make migrations:
python manage.py makemigrations - Run migrations:
python manage.py migrate
Triggers introduce performance overhead. In certain cases, you may need to disable triggers while performing bulk operations. To turn off all triggers, a decorator is provided:
from postgres_audit_triggers.decorators import disable_triggers
@disable_triggers
def foo():
# auditing will not be triggered on any database operations performed here
Bar.objects.bulk_create(items)
Metadata
Release files for postgres-audit-triggers 1.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| postgres-audit-triggers-1.2.1.tar.gz | 11.7 kB | Without provenance | Details for postgres-audit-triggers-1.2.1.tar.gz |
Release files / postgres-audit-triggers-1.2.1.tar.gz
| Download URL | postgres-audit-triggers-1.2.1.tar.gz |
|---|---|
| Size | 11.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4e9ec42e7ba8fd6beeafd0cb9b4fefb09d47cec4dd8d4ac4672e32985f02c8ce
|
|
BLAKE2b-256 checksum How to use checksums |
46e570b773c310adae22e1b6e89dcc4e1b4b3ee26d718606ee9c6a8cb56ff86c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/3.5.2
|
Security for postgres-audit-triggers 1.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.