{ "info": { "author": "Datapunt Amsterdam", "author_email": "datapunt@amsterdam.nl", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: Mozilla Public License 2.0 (MPL 2.0)", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: System :: Logging" ], "description": "\nFor a Django implementation (which uses this library) see https://github.com/Amsterdam/django-audit-log\n\n# DataPunt Audit Log\n\nDataPunt Audit Log is a simple python package that provides a simple way\nto allow for uniform audit logs across all our applications. \n\nThe AuditLogger class can be provided with info and will log to stdout. \n\nEventually this logger wil run inside our docker containers. Filebeat\nwill be used to read the audit logs from those containers, and will send \nthem along to logstash, which in turn sends them to elastic. \n\n\n## Quick start\n\n1. Install using pip\n\n ```bash\n pip install datapunt_audit_log\n ```\n\n2. Add logs to your code\n\n ```python\n AuditLogger()\\\n .set_http_request(method='GET', url='https://localhost', user_agent='Test')\\\n .info('This is a log message')\\\n .send_log()\n ```\n\n\n## Basic Usage\n\nThe audit log is simple in its usage. There are several methods to set context-info\nregarding the request:\n\n```python\nset_http_request(self, method: str, url: str, user_agent: str = '') -> 'AuditLogger'\nset_http_response(self, status_code: int, reason: str, headers: dict = None) -> 'AuditLogger'\nset_user(self, authenticated: bool, provider: str, email: str, roles: list = None, ip: str = '', realm: str = '') -> 'AuditLogger'\nset_filter(self, object_name: str, kwargs: dict) -> 'AuditLogger'\nset_results(self, results: list = None) -> 'AuditLogger'\n```\n\nAlso, a log message and loglevel can be provided to indicate what the request is actually doing. \nThis is done by calling one of the following methods:\n\n```python\ndebug(self, msg: str) -> 'AuditLogger'\ninfo(self, msg: str) -> 'AuditLogger'\nwarning(self, msg: str) -> 'AuditLogger'\nerror(self, msg: str) -> 'AuditLogger'\ncritical(self, msg: str) -> 'AuditLogger'\n```\n\nNote that each of these methods returns `self`. We use an adaption of the builder pattern here to \nmake the logger simple in use. It enables us to do:\n\n```python\nAuditLogger()\\\n .set_http_request(method='GET', url='https://localhost', user_agent='Test')\\\n .info('This is a log message')\\\n .send_log()\n```\n\n\n## Context info\n\nAlthough none of the methods are required before sending the log (you could even send an empty log), \nyou are strongly urged to add as much info as possible before sending the log. This will\neventually result in a complete audit log that contains the necessary details to perform proper \nauditing.\n\n\n### HTTP request\n`AuditLogger().set_http_request(self, method: str, url: str, user_agent: str = '')` allows to \nprovide more info about the HTTP request that has been executed.\n\nThis method will add the following details to the log:\n\n```json\n\"http_request\": {\n \"method\": \"get|post|head|options|etc..\",\n \"url\": \"https://datapunt.amsterdam.nl\",\n \"user_agent\": \"full browser user agent\"\n},\n```\n\n### HTTP response\n`AuditLogger().set_http_response(self, status_code: int, reason: str, headers: dict = None)` allows\nto provide more info detailing the HTTP response that was returned to the user. \n\nThis method will add the following details to the log:\n\n```json\n\"http_response\": {\n \"status_code\": \"http status code\",\n \"reason\": \"http status reason\",\n \"headers\": {\n \"key\": \"value\"\n}\n```\n\n\n### User\n`AuditLogger().set_user(self, authenticated: bool, provider: str, email: str, roles: list = None, ip: str = '', realm: str = '')`\nallows to provide details regarding the user that executed a specific request.\n\nThis method will add the following details to the log:\n\n```json\n\"user\": {\n \"authenticated\": \"True/False\",\n \"provider\": \"auth backend the user authenticated with\",\n \"realm\": \"optional realm when using keycloak or another provider\",\n \"email\": \"email of logged in user\",\n \"roles\": \"roles attached to the logged in user\",\n \"ip\": \"ip address\"\n}\n```\n\n### Filter \n`AuditLogger().set_filter(self, object_name: str, kwargs: dict)` allows to provide\ninfo on the requested type of object and the filters that have been used (a user searches \nfor 'terms', which are matched on specific 'fields' of the 'object').\n\nThis method will add the following details to the log:\n\n```json\n\"filter\": {\n \"object\": \"Object name that is requested\",\n \"kwargs\": {\n 'fields': 'filter values',\n 'more_fields': 'more filter values'\n }\n}\n```\n\n### Results\n`AuditLogger().set_results(self, results: list)` allows to store what results have been returned \nto the user. \n\nIt is up to the developer to decide whether the amount of data that would be added here will \nbecome a burden instead of a blessing.\n\nThis method will add the following details to the log:\n\n```json\n\"results\": {\n ...\n }\n```\n\n\n", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/Amsterdam/auditlog", "keywords": "", "license": "Mozilla Public License 2.0", "maintainer": "", "maintainer_email": "", "name": "datapunt-audit-log", "package_url": "https://pypi.org/project/datapunt-audit-log/", "platform": "", "project_url": "https://pypi.org/project/datapunt-audit-log/", "project_urls": { "Homepage": "https://github.com/Amsterdam/auditlog" }, "release_url": "https://pypi.org/project/datapunt-audit-log/0.4.0/", "requires_dist": [ "pytest ; extra == 'dev'", "pytest-cov ; extra == 'dev'", "twine ; extra == 'dev'", "bump2version ; extra == 'dev'" ], "requires_python": "", "summary": "A simple python package to enable uniform audit logging", "version": "0.4.0", "yanked": false, "yanked_reason": null }, "last_serial": 8472365, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "18a6e298ebdd01386440689b8624af61", "sha256": "ab0b789a83bfcc77c7e7c8442db808db84c57989fe44ba154ef05a247d2bdab6" }, "downloads": -1, "filename": "datapunt_audit_log-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "18a6e298ebdd01386440689b8624af61", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10152, "upload_time": "2019-10-28T15:30:05", "upload_time_iso_8601": "2019-10-28T15:30:05.342778Z", "url": "https://files.pythonhosted.org/packages/fe/a6/9954d48de5245a45e1277214e1cecc7e3cd53a839e82cd49f10ac8d44778/datapunt_audit_log-0.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "297e05930611d33924aca8c08a6496b9", "sha256": "15bbdaed97650c2797755bb3e6cca50ba7c45ed9eba496cb50cc787ebde5c966" }, "downloads": -1, "filename": "datapunt-audit-log-0.1.0.tar.gz", "has_sig": false, "md5_digest": "297e05930611d33924aca8c08a6496b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9938, "upload_time": "2019-10-28T15:30:07", "upload_time_iso_8601": "2019-10-28T15:30:07.927582Z", "url": "https://files.pythonhosted.org/packages/35/4c/121427940e43d4cd16f7e9231bf304fe487d416e8b9baaa1ecd5ffd5ebaf/datapunt-audit-log-0.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "5d318bcc1a9098226ead57a5df889a2f", "sha256": "880ccb41f2f0f4c393623a7248a362310ad0b68e4a9f3fbe3309bae1e8cce311" }, "downloads": -1, "filename": "datapunt_audit_log-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "5d318bcc1a9098226ead57a5df889a2f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10149, "upload_time": "2019-10-28T15:57:46", "upload_time_iso_8601": "2019-10-28T15:57:46.360433Z", "url": "https://files.pythonhosted.org/packages/b1/3e/f62db0822b6c6e77a6f5cd2f7acc653f5cadd8ac475d88223f498ffc6c3a/datapunt_audit_log-0.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "85ad217ad98e2225586d5c1273411f7c", "sha256": "5ecb122a00a972645b3fcbdb5288b230639f0a58facccd2e2a9f6ab01d2aef6e" }, "downloads": -1, "filename": "datapunt-audit-log-0.1.1.tar.gz", "has_sig": false, "md5_digest": "85ad217ad98e2225586d5c1273411f7c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9941, "upload_time": "2019-10-28T15:57:47", "upload_time_iso_8601": "2019-10-28T15:57:47.961997Z", "url": "https://files.pythonhosted.org/packages/eb/d6/daf79b1b6056061ee97717bbef1847a66b7da63db742cf60d03635019812/datapunt-audit-log-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.1": [ { "comment_text": "", "digests": { "md5": "faf3c5f3e27091ca9dab241e4039d1eb", "sha256": "87983071b758500069788be42178628266c686d223e10224c5e59d1e4c36d465" }, "downloads": -1, "filename": "datapunt_audit_log-0.2.1-py3-none-any.whl", "has_sig": false, "md5_digest": "faf3c5f3e27091ca9dab241e4039d1eb", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10147, "upload_time": "2019-10-31T14:03:51", "upload_time_iso_8601": "2019-10-31T14:03:51.804546Z", "url": "https://files.pythonhosted.org/packages/2d/69/7480d7486e8eb3d0f7b532f50bd4f8ee72dfca2df43e5e3b364e32070a7b/datapunt_audit_log-0.2.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "f1f80c1c43cbf062147e591c24d133c1", "sha256": "259f452fedd91f44b93ea0fcc2f291e5654102d6bbc4e4e0ec5e37ec72ca16e4" }, "downloads": -1, "filename": "datapunt-audit-log-0.2.1.tar.gz", "has_sig": false, "md5_digest": "f1f80c1c43cbf062147e591c24d133c1", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9947, "upload_time": "2019-10-31T14:03:53", "upload_time_iso_8601": "2019-10-31T14:03:53.328736Z", "url": "https://files.pythonhosted.org/packages/a0/3d/4636dcd6b3fb70961beaa9fd70908c38f92f92c1a56b7b2fccd49c3461cf/datapunt-audit-log-0.2.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "b971fc0ebeca281bb7f34cb6915662d5", "sha256": "eb955f2abad0cc1c943a53fc6288689e718d03bc37c8132927c31f92095951dc" }, "downloads": -1, "filename": "datapunt_audit_log-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "b971fc0ebeca281bb7f34cb6915662d5", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10228, "upload_time": "2019-12-20T11:18:00", "upload_time_iso_8601": "2019-12-20T11:18:00.127458Z", "url": "https://files.pythonhosted.org/packages/1f/1a/438d5a2e465310631a57464552efa368d0c2cebc01ab449258d014433a19/datapunt_audit_log-0.3.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "4b52083d4519115f8b97159e8b9432eb", "sha256": "8e84523b10b14096261f5a55608d46b315c42c915ef77d2ce8f131a3458740e1" }, "downloads": -1, "filename": "datapunt-audit-log-0.3.0.tar.gz", "has_sig": false, "md5_digest": "4b52083d4519115f8b97159e8b9432eb", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10031, "upload_time": "2019-12-20T11:18:01", "upload_time_iso_8601": "2019-12-20T11:18:01.945456Z", "url": "https://files.pythonhosted.org/packages/9a/b4/2cd43046ebdd67ed3014feabfc3a4cec4aa57bd88a835101ffc2d304443d/datapunt-audit-log-0.3.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "11c27a634a7059e912fc50e450b4bd3f", "sha256": "d7f8375d2adde33a944783b5290670ce7b71c4e9583da7079753c5edb82a2675" }, "downloads": -1, "filename": "datapunt_audit_log-0.3.1-py3-none-any.whl", "has_sig": false, "md5_digest": "11c27a634a7059e912fc50e450b4bd3f", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10247, "upload_time": "2020-01-20T11:42:33", "upload_time_iso_8601": "2020-01-20T11:42:33.303440Z", "url": "https://files.pythonhosted.org/packages/27/d8/5f5259020d2f80f74be6c91e7a075813b85e6d05fc002d9a129aa467606c/datapunt_audit_log-0.3.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "b9657e44ff47e6032d44056cf31f0b5e", "sha256": "930b270dab64543a477bfffb1bfd6607788d8662ae6dbf0c89577e4a5700c810" }, "downloads": -1, "filename": "datapunt-audit-log-0.3.1.tar.gz", "has_sig": false, "md5_digest": "b9657e44ff47e6032d44056cf31f0b5e", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 10057, "upload_time": "2020-01-20T11:42:34", "upload_time_iso_8601": "2020-01-20T11:42:34.597647Z", "url": "https://files.pythonhosted.org/packages/8f/b0/1617a36b507e367c5681759aac06c4bcb5cf3989eebb1626905d73201efd/datapunt-audit-log-0.3.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "93ad200bbfddf58c36ebeaf4e01cf8ee", "sha256": "ea2dbe0d9bb4f1b237f633523df3ab4452f698ce992c474df69829ff64add441" }, "downloads": -1, "filename": "datapunt_audit_log-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "93ad200bbfddf58c36ebeaf4e01cf8ee", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10248, "upload_time": "2020-10-22T06:46:59", "upload_time_iso_8601": "2020-10-22T06:46:59.483921Z", "url": "https://files.pythonhosted.org/packages/e0/c3/8373237b42ca82ac51fc4e9a4c734dff2700933b4a23994815c973b91037/datapunt_audit_log-0.4.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "429f387e5c7b18af4f30c3fa24f801b7", "sha256": "19c8b2a427cc8d4431ab91f486451946da1a3e0f1e1a839aa4d56b11ba36ca2a" }, "downloads": -1, "filename": "datapunt-audit-log-0.4.0.tar.gz", "has_sig": false, "md5_digest": "429f387e5c7b18af4f30c3fa24f801b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11275, "upload_time": "2020-10-22T06:47:01", "upload_time_iso_8601": "2020-10-22T06:47:01.050021Z", "url": "https://files.pythonhosted.org/packages/1b/8b/c01a551a3a73d2777da2f232198f49c34c84fc278c13d20b98216e05a9c9/datapunt-audit-log-0.4.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "93ad200bbfddf58c36ebeaf4e01cf8ee", "sha256": "ea2dbe0d9bb4f1b237f633523df3ab4452f698ce992c474df69829ff64add441" }, "downloads": -1, "filename": "datapunt_audit_log-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "93ad200bbfddf58c36ebeaf4e01cf8ee", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10248, "upload_time": "2020-10-22T06:46:59", "upload_time_iso_8601": "2020-10-22T06:46:59.483921Z", "url": "https://files.pythonhosted.org/packages/e0/c3/8373237b42ca82ac51fc4e9a4c734dff2700933b4a23994815c973b91037/datapunt_audit_log-0.4.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "429f387e5c7b18af4f30c3fa24f801b7", "sha256": "19c8b2a427cc8d4431ab91f486451946da1a3e0f1e1a839aa4d56b11ba36ca2a" }, "downloads": -1, "filename": "datapunt-audit-log-0.4.0.tar.gz", "has_sig": false, "md5_digest": "429f387e5c7b18af4f30c3fa24f801b7", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11275, "upload_time": "2020-10-22T06:47:01", "upload_time_iso_8601": "2020-10-22T06:47:01.050021Z", "url": "https://files.pythonhosted.org/packages/1b/8b/c01a551a3a73d2777da2f232198f49c34c84fc278c13d20b98216e05a9c9/datapunt-audit-log-0.4.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }