Flask-Auditor
Flask-Auditor is an extension for Flask that extract request and response to audit log.
Installing
Install and upgrade using pip:
$ pip install flask-auditor
A simple example
from flask import Flask
from flask import jsonify
from flask_auditor import FlaskAuditor
app = Flask(__name__)
app.config['AUDIT_LOGGER_SOURCE_NAME'] = 'auditLogger'
auditor = FlaskAuditor(app)
@app.route('/api/v1/users', methods=['GET'])
@auditor.log(action_id='LIST_USERS', description='Fetch a list of users')
def list_users():
resp = jsonify({
'users': [
{
'id': 1,
'name': 'Makai'
},
{
'id': 2,
'name': 'TNiaH'
}
]
})
resp.status_code = 200
return resp
if __name__ == '__main__':
app.run(debug=True)
Audit Log Example
{
"source": "auditLogger",
"startTime": "2024-05-22 11:45:42",
"actionId": "LIST_USERS",
"description": "Fetch a list of users",
"request": {
"serverHost": "127.0.0.1",
"serverPort": 5000,
"requestID": "N/A",
"remoteIP": "127.0.0.1",
"remotePort": 34038,
"protocol": "HTTP/1.1",
"host": "127.0.0.1:5000",
"method": "GET",
"uri": "/api/v1/users?page=1&limit=10",
"uriPath": "/api/v1/users",
"routePath": "/api/v1/users",
"referer": "N/A",
"userAgent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36",
"contentLength": "N/A",
"headers": {
"Accept-Encoding": "gzip, deflate, br"
},
"queryParams": {
"page": [
"1"
],
"limit": [
"10"
]
},
"requestBody": {}
},
"response": {
"statusCode": 200,
"status": "OK",
"responseSize": 120
},
"latency": 0.00011
}
Metadata
Release files for flask-auditor 0.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 | |
|---|---|---|---|
| flask_auditor-0.2.1.tar.gz | 14.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| flask_auditor-0.2.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 27.5 kB
Release files / flask_auditor-0.2.1.tar.gz
| Download URL | flask_auditor-0.2.1.tar.gz |
|---|---|
| Size | 14.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f85e47bdc174bde25beb037727203123cac33be5d615debf6b436dc949651ca5
|
|
BLAKE2b-256 checksum How to use checksums |
831e385928f1dcc735787d1451c193dcc87cae627dcf9f6611d61d1490601902
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.16
|
Release files / flask_auditor-0.2.1-py3-none-any.whl
| Download URL | flask_auditor-0.2.1-py3-none-any.whl |
|---|---|
| Size | 13.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
61e84bd6a068277a2102475f85371a815347f3735980651d55e8ba9af283fcb5
|
|
BLAKE2b-256 checksum How to use checksums |
33486d93bef413da558b0e9086d7fb409e4bc05338aa834e03742834b0581792
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.0 CPython/3.8.16
|