Skip to main content

Sdilena knihovna pro auditni logovani v SYSNET mikrosluzbach

Project description

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.

Project details


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.1.tar.gz (122.7 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.1-py3-none-any.whl (40.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sysnet_audit-0.2.1.tar.gz
  • Upload date:
  • Size: 122.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sysnet_audit-0.2.1.tar.gz
Algorithm Hash digest
SHA256 3397b3d1e0c30b7783670343f90a14b599cdf82c8548d364634b44dd076ae6aa
MD5 451986b02c34b236f78a07cd6d03cec3
BLAKE2b-256 62013dde422186ad5bf3bdae5723fc91cdbdf4d8e8791864be2412801221a0ae

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sysnet_audit-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 40.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for sysnet_audit-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 bec0595f0d933a86eb146b3fe864c3a26a45173fd8d01a2e0ee3d72f7f2a8d0f
MD5 7addbc1461e26e55ec5de212f3866269
BLAKE2b-256 2f29d949b1f1b9d329c0ec711934f538a1cfe964e503be12608222f951433079

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page