{ "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 the Python only implementation (which is used by this library) see https://github.com/Amsterdam/python-audit-log\n\n\n# DataPunt Django Audit Log\n\nDataPunt Audit Log is a simple Django app that will log all incoming requests\nand their corresponding responses to a configurable endpoint. \n\nDuring the process request phase, the logger is attached to the request. Before \nreturning a response the app can easily provide extra context. In the process\nresponse phase the audit_log middleware will send the log. \n\n\n## Links\n- [Quick Start](#quick-start)\n- [Default Context Info](#default-context-info)\n- [Custom Optional Context Info](#custom-optional-context-info)\n- [Django Rest Framework](#django-rest-framework)\n\n\n## Quick start\n\n1. Install using pip\n\n ```bash\n pip install datapunt_django_audit_log\n ```\n\n2. Add \"django_audit_log\" to your INSTALLED_APPS:\n\n ```python\n INSTALLED_APPS = [\n ...\n 'django_audit_log',\n ]\n ```\n\n3. Add the AuditLogMiddleware to your MIDDLEWARE:\n\n ```python\n MIDDLEWARE = [\n ...\n 'django_audit_log.middleware.AuditLogMiddleware',\n ]\n ```\n\n4. When using the Django Rest Framework, let your viewsets extend `AuditLogReadOnlyViewset`\nor `AuditLogViewSet`. This will automatically add context to the audit log regarding\nfilters, results and executed actions (see - [Django Rest Framework](#django-rest-framework)).\n\n ```python\n class MyViewSet(AuditLogViewSet):\n queryset = SomeModel.objects.all()\n ```\n\n5. Set the AUDIT_LOG_EXEMPT_URLS setting to make sure certain urls will not be logged \n(e.g. health check urls). \n\n ```python\n # If a URL path matches a regular expression in this list, the request will not be redirected to HTTPS.\n # The AuditLogMiddleware strips leading slashes from URL paths, so patterns shouldn\u2019t include them, e.g.\n # [r'foo/bar$']\n AUDIT_LOG_EXEMPT_URLS = []\n ```\n\n\nAt this point all requests/responses will be logged. For providing extra context\n(which you are strongly urged to do so), see next chapters.\n\n## Default context info\n\nBy default the audit log sends the following json structure per request:\n\n```json\n{\n \"http_request\": {\n \"method\": \"get|post|head|options|etc..\",\n \"url\": \"https://datapunt.amsterdam.nl?including=querystring\",\n \"user_agent\": \"full browser user agent\"\n },\n \"http_response\": {\n \"status_code\": \"http status code\",\n \"reason\": \"http status reason\",\n \"headers\": {\n \"key\": \"value\"\n }\n },\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\nEach json entry is set by its corresponding method. In this case, \nthe middleware sets them automatically by calling\n`set_http_request()` and `set_user_fom_request()` \nin the process_request method. In the process_response method the\nlast data is set by invoking `set_http_response()`.\n\nAfter the response has been processed the middleware automatically\ncreates the log item by calling `send_log()`. \n\n## Custom optional context info\n\nPer request it is possible to add optional context info. For a complete\naudit log, you are strongly urged to add more info inside your view.\n\nAdding extra context is quite simple. The audit_log object has been added\nto the request by the middleware. Therefore every view can simply access \nit via the request object.\n\n### Filter \n`request.audit_log.set_filter(self, object_name, fields, terms)` allows to provide\ninfo on the requested type of object and the filters that have been used \n(a user searches for 'terms', which are matched on specific 'fields' of the \n'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 \"fields\": \"Fields that are being filtered on, if applicable\",\n \"terms\": \"Search terms, if applicable\"\n }\n```\n\n### Results\n`request.audit_log.set_results(self, results)` allows to pass a json dict\ndetailing exactly what results have been returned to the user. \n\nIt is up to the developer to decide whether the amount of \ndata that would be added here will become a burden instead\nof a blessing.\n\nThis method will add the following details to the log:\n\n```json\n\"results\": {\n ...\n }\n```\n\n### Message and loglevel\nAt last, a log message and loglevel can be provided to indicate \nwhat the request is actually doing. This is done by calling \none of the following methods:\n\n```python\nrequest.audit_log.debug(self, msg)\nrequest.audit_log.info(self, msg)\nrequest.audit_log.warning(self, msg)\nrequest.audit_log.error(self, msg)\nrequest.audit_log.critical(self, msg)\n```\n\nThese methods will add the following details to the log:\n\n```json\n\"type\": \"DEBUG|INFO|WARNING|ERROR|etc\",\n\"message\": \"log message\"\n```\n\n## Django Rest Framework\nTwo base-ViewSets are available if you use the Django Rest Framework.\n\nThe `AuditLogReadOnlyViewSet` extends the `ReadOnlyModelViewSet` and overrides\nthe `retrieve()` and `list()` methods. The `AuditLogViewSet` extends the `AuditLogReadOnlyViewSet`\nand overrides the remaining (non-read-only) methods `create()`, `update()` and `destroy()`.\n\nOur classes inspect the request and will automatically add extra context information\nto the audit log. This context information provides info regarding filters, results\nand the action that is being performed.\n\nNote that by default `list()` will not add the results to the log, unless the `audit_log_list_response`\nattribute is set. Only do so when the amount of data inside the list response is suitable\nto store inside a log entry.\n\n```python\nclass MyViewSet(AuditLogViewSet):\n audit_log_list_response = True\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-django-audit-log", "package_url": "https://pypi.org/project/datapunt-django-audit-log/", "platform": "", "project_url": "https://pypi.org/project/datapunt-django-audit-log/", "project_urls": { "Homepage": "https://github.com/Amsterdam/auditlog" }, "release_url": "https://pypi.org/project/datapunt-django-audit-log/0.4.0/", "requires_dist": [ "django", "datapunt-audit-log", "pytest ; extra == 'dev'", "pytest-cov ; extra == 'dev'", "twine ; extra == 'dev'", "bump2version ; extra == 'dev'" ], "requires_python": "", "summary": "A simple Django app to enable audit logging", "version": "0.4.0", "yanked": false, "yanked_reason": null }, "last_serial": 6537122, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "255f59ef21ffb50ad750c1517bff655b", "sha256": "d07177741cfed5f9c06b75dff410a46a84cfe5a13ca55a43fcf7beda6d7872d0" }, "downloads": -1, "filename": "datapunt_django_audit_log-0.1.0-py3-none-any.whl", "has_sig": false, "md5_digest": "255f59ef21ffb50ad750c1517bff655b", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10491, "upload_time": "2019-10-28T15:40:50", "upload_time_iso_8601": "2019-10-28T15:40:50.245866Z", "url": "https://files.pythonhosted.org/packages/51/f6/f2fcdcbde9c4a1a3a3c23fe58f2f100275ef65249852615e007c5f1b468c/datapunt_django_audit_log-0.1.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "df9c28c275a415d70f3cf5c417ce7dfa", "sha256": "21060cb7c727f804141630664fb6303debd136190aebe2d2bbd00b74c0171a7d" }, "downloads": -1, "filename": "datapunt-django-audit-log-0.1.0.tar.gz", "has_sig": false, "md5_digest": "df9c28c275a415d70f3cf5c417ce7dfa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9991, "upload_time": "2019-10-28T15:40:52", "upload_time_iso_8601": "2019-10-28T15:40:52.510295Z", "url": "https://files.pythonhosted.org/packages/82/fd/72b34109b5537a004b05f5d0e9d11b69f03d64f38a994e93e8d35023de1f/datapunt-django-audit-log-0.1.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.1.1": [ { "comment_text": "", "digests": { "md5": "1cfc3e114b6613622bb261a98c94e401", "sha256": "19bb089775ad75ad1dbaaa64818d129f55d12bb4e4b3c8d0fc5c879b6ca46eac" }, "downloads": -1, "filename": "datapunt_django_audit_log-0.1.1-py3-none-any.whl", "has_sig": false, "md5_digest": "1cfc3e114b6613622bb261a98c94e401", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 10491, "upload_time": "2019-10-28T16:05:58", "upload_time_iso_8601": "2019-10-28T16:05:58.314804Z", "url": "https://files.pythonhosted.org/packages/be/2b/d643da1d57093b8f5fc7489db5c635f4831d46321d81bd1c8d62d4c8cf78/datapunt_django_audit_log-0.1.1-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "26bd3c052820a8636991db117f27a951", "sha256": "5c0606f82cf55c1a3f7c330f9ed06f69b1d98105fad993802c8f6a2c830243d2" }, "downloads": -1, "filename": "datapunt-django-audit-log-0.1.1.tar.gz", "has_sig": false, "md5_digest": "26bd3c052820a8636991db117f27a951", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9994, "upload_time": "2019-10-28T16:06:00", "upload_time_iso_8601": "2019-10-28T16:06:00.106784Z", "url": "https://files.pythonhosted.org/packages/78/2d/2536269961494122d02c46fdb79ecade1bc5b63113f8b844219bed45a118/datapunt-django-audit-log-0.1.1.tar.gz", "yanked": false, "yanked_reason": null } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "c27aed9754d1ff1b314da53d13eae0c3", "sha256": "eb3de36075398c2067a923c1b6c4a5c67d79b6e69e613abdc310f3f262f263eb" }, "downloads": -1, "filename": "datapunt_django_audit_log-0.2.0-py3-none-any.whl", "has_sig": false, "md5_digest": "c27aed9754d1ff1b314da53d13eae0c3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12157, "upload_time": "2019-10-31T14:09:39", "upload_time_iso_8601": "2019-10-31T14:09:39.831339Z", "url": "https://files.pythonhosted.org/packages/cc/2c/56bbffb679d561b5d6044dced16ff649ecb2a47ac9d1e01ad1c4e5cdda8e/datapunt_django_audit_log-0.2.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "f44d2a57bb44befbc722a82598062725", "sha256": "1b37b6f8a9df4db70b3cfec792cd42f6eb1bf34c18b5345ab00fe03b72122ed3" }, "downloads": -1, "filename": "datapunt-django-audit-log-0.2.0.tar.gz", "has_sig": false, "md5_digest": "f44d2a57bb44befbc722a82598062725", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 11309, "upload_time": "2019-10-31T14:09:41", "upload_time_iso_8601": "2019-10-31T14:09:41.454865Z", "url": "https://files.pythonhosted.org/packages/32/43/e5a2107692cbf105fbca39da27faafdd053809e804d887be8d5c9f8188fa/datapunt-django-audit-log-0.2.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "10b0dbf25aea9a88866aac16d9142dc3", "sha256": "cbc67b617f3ee9bce3ac78c14e48f2a72108dc1ccc494f3ee15b6a5644902815" }, "downloads": -1, "filename": "datapunt_django_audit_log-0.3.0-py3-none-any.whl", "has_sig": false, "md5_digest": "10b0dbf25aea9a88866aac16d9142dc3", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 12881, "upload_time": "2020-01-08T14:23:26", "upload_time_iso_8601": "2020-01-08T14:23:26.088685Z", "url": "https://files.pythonhosted.org/packages/af/a3/9e61eaff3b2e7cbd9e68b91e33991e928bdee6648ff2ba4df466401d8acc/datapunt_django_audit_log-0.3.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "a4f4dc729e28bad40c8192ce17cd4c2d", "sha256": "82e091b92e6004f65f5d221ccbb00a32b9fbb081f9c23bfb79f13cc710c28b0d" }, "downloads": -1, "filename": "datapunt-django-audit-log-0.3.0.tar.gz", "has_sig": false, "md5_digest": "a4f4dc729e28bad40c8192ce17cd4c2d", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12572, "upload_time": "2020-01-08T14:23:27", "upload_time_iso_8601": "2020-01-08T14:23:27.704727Z", "url": "https://files.pythonhosted.org/packages/b1/8b/bbcad2b61745073370ae33e48d4f1ab2ca1ae27f4371fed2056a1e817629/datapunt-django-audit-log-0.3.0.tar.gz", "yanked": false, "yanked_reason": null } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "28e9536021954899394ca1176aa464af", "sha256": "74dbb738003fb4d871b1e6a87d05e35b4c6f7a28730363dae07afe4673a7890b" }, "downloads": -1, "filename": "datapunt_django_audit_log-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "28e9536021954899394ca1176aa464af", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13494, "upload_time": "2020-01-29T10:20:19", "upload_time_iso_8601": "2020-01-29T10:20:19.644137Z", "url": "https://files.pythonhosted.org/packages/54/be/2c6e13da09298ffa18cb6aeeeffd35b1d3cab0c45db69c8b0daab5c74d78/datapunt_django_audit_log-0.4.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "1fbdf2338bf4146c3b09b5058a1083a4", "sha256": "aea0d928af6c192ac3abcc50a61cd8e42f7f920afeec788b04d71cf6ec36a2e0" }, "downloads": -1, "filename": "datapunt-django-audit-log-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1fbdf2338bf4146c3b09b5058a1083a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13077, "upload_time": "2020-01-29T10:20:21", "upload_time_iso_8601": "2020-01-29T10:20:21.773247Z", "url": "https://files.pythonhosted.org/packages/9e/41/add4b831f36182acb0b0909766e44474e27d25d72a776b7f39b5c158d035/datapunt-django-audit-log-0.4.0.tar.gz", "yanked": false, "yanked_reason": null } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "28e9536021954899394ca1176aa464af", "sha256": "74dbb738003fb4d871b1e6a87d05e35b4c6f7a28730363dae07afe4673a7890b" }, "downloads": -1, "filename": "datapunt_django_audit_log-0.4.0-py3-none-any.whl", "has_sig": false, "md5_digest": "28e9536021954899394ca1176aa464af", "packagetype": "bdist_wheel", "python_version": "py3", "requires_python": null, "size": 13494, "upload_time": "2020-01-29T10:20:19", "upload_time_iso_8601": "2020-01-29T10:20:19.644137Z", "url": "https://files.pythonhosted.org/packages/54/be/2c6e13da09298ffa18cb6aeeeffd35b1d3cab0c45db69c8b0daab5c74d78/datapunt_django_audit_log-0.4.0-py3-none-any.whl", "yanked": false, "yanked_reason": null }, { "comment_text": "", "digests": { "md5": "1fbdf2338bf4146c3b09b5058a1083a4", "sha256": "aea0d928af6c192ac3abcc50a61cd8e42f7f920afeec788b04d71cf6ec36a2e0" }, "downloads": -1, "filename": "datapunt-django-audit-log-0.4.0.tar.gz", "has_sig": false, "md5_digest": "1fbdf2338bf4146c3b09b5058a1083a4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13077, "upload_time": "2020-01-29T10:20:21", "upload_time_iso_8601": "2020-01-29T10:20:21.773247Z", "url": "https://files.pythonhosted.org/packages/9e/41/add4b831f36182acb0b0909766e44474e27d25d72a776b7f39b5c158d035/datapunt-django-audit-log-0.4.0.tar.gz", "yanked": false, "yanked_reason": null } ], "vulnerabilities": [] }