Skip to main content

sysnet-audit

Sdílená Python knihovna pro auditní logování napříč FastAPI mikroslužbami SYSNET s.r.o.

pip install sysnet-audit

Python 3.11+ FastAPI Beanie 2.x pymongo 4+

Tests Typing

PyPI AGPLv3+


Distribuční název: sysnet-audit
Import path: audit_lib
Repozitář: github.com/SYSNET-CZ/audit


Quick start

from contextlib import asynccontextmanager
from fastapi import FastAPI, Depends
from audit_lib import (
    init_audit, get_audit_backend, get_audit_logger,
    AuditLogger, AuditActor, AuditResource, AuditSettings,
)

@asynccontextmanager
async def lifespan(app: FastAPI):
    client = await init_audit(AuditSettings())
    yield
    await get_audit_backend().aclose()
    if client is not None:
        await client.aclose()

app = FastAPI(lifespan=lifespan)

@app.delete("/users/{user_id}")
async def delete_user(
    user_id: str,
    audit: AuditLogger = Depends(get_audit_logger),
):
    await audit.log(
        actor=AuditActor(sub="user-uuid"),
        action="user.delete",
        resource=AuditResource(type="user", id=user_id),
    )

Proměnné prostředí

Prefix: AUDIT_

Proměnná Výchozí Popis
AUDIT_SERVICE_NAME — (povinné) Identifikace mikroslužby
AUDIT_MONGO_URI mongodb://localhost:27017 Connection string MongoDB
AUDIT_MONGO_DB audit Název databáze
AUDIT_ENABLED true Globální vypínač auditování
AUDIT_KAFKA_BOOTSTRAP_SERVERS None Adresy Kafka brokerů (pro Topologii B)

Vývoj a testování

git clone git@github.com:SYSNET-CZ/audit.git
cd audit
uv venv .venv --python 3.12
source .venv/bin/activate
uv pip install -e ".[dev,kafka]"
pytest

Licence

AGPLv3+ — SYSNET s.r.o.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sysnet_audit-0.2.2.tar.gz (146.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sysnet_audit-0.2.2-py3-none-any.whl (40.8 kB view details)

Uploaded Python 3

File details

Details for the file sysnet_audit-0.2.2.tar.gz.

File metadata

  • Download URL: sysnet_audit-0.2.2.tar.gz
  • Upload date:
  • Size: 146.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for sysnet_audit-0.2.2.tar.gz
Algorithm Hash digest
SHA256 c5fd3646e124ff221e5aedf687505765f2a7be5a9f3e771bf3e1398d912044db
MD5 e6ec170f23de6cc81c9c930610d6f9d8
BLAKE2b-256 cc71129f40b5c7a0c635340e78d4863f6d7b69b61f32485c3c61d7e3be69ed71

See more details on using hashes here.

File details

Details for the file sysnet_audit-0.2.2-py3-none-any.whl.

File metadata

  • Download URL: sysnet_audit-0.2.2-py3-none-any.whl
  • Upload date:
  • Size: 40.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/7.0.0 CPython/3.11.15

File hashes

Hashes for sysnet_audit-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 dc1849f11f7a0f1c6d40b4cbaaaa7310ab4f8f3a80bd005a6e054d2def49307f
MD5 b51c7ce1cd11c28147ee4501a44d9abd
BLAKE2b-256 b2ce1890a13d11271491163ab1c26b504dcbaf8dba6ebb985895f2bce2aa9d3d

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.2.2 This release

2 files

0.2.1

2 files

0.2.0

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page