A utility package for kolomoni agency banking microservices
Project description
# Shared Python Utilities
== Custom Auth Service
In order to use the Custom Auth Middleware, kindly set the following
[source,bash]
---
poetry add pykolofinance
---
[source,bash]
---
pip install pykolofinance
---
[source,bash]
---
AUTH_SERVICE_BASE_URL=
---
## Usage
1. Install the package
[source,bash]
---
poetry add pykolofinance
---
2. Add `pykolofinance` to installed apps in django
3. update `REST_FRAMEWORK` settings as showing below
[source,python]
---
REST_FRAMEWORK = {
...
# 'DATE_INPUT_FORMATS': ["%d/%m/%Y", ],
'DEFAULT_AUTHENTICATION_CLASSES': (
"pykolofinance.authentication.CustomJWTAuthentication",
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
),
...
}
---
=== Manage Migrations
Whenever you make changes to models, you need to generate migrations locally before pushing your code to the repo. In order to generate migrations, kindly run the following command in another terminal window while your main app is also running
== Logging
The service includes a middleware that logs both requests and responses to Elasticsearch (ELK). To enable logging, specify the `ELK_LOGGER_URL` in your environment variables.
=== Configuration
Ensure your `.env` file includes the following:
[source,bash]
----
ELK_LOGGER_URL=https://your-elasticsearch-url:9200
----
=== Middleware Integration
The logging middleware is already integrated into the application. It captures API interactions and stores them in Elasticsearch for monitoring and analysis.
=== Skip URL Name
You can skip logging for specific API endpoints by setting `API_LOGGER_SKIP_URL_NAME` in your `settings.py`. Example:
[source,python]
----
API_LOGGER_SKIP_URL_NAME = ['url_name1', 'url_name2']
----
=== Skip Namespace
Skip logging for entire apps by specifying their namespaces in `API_LOGGER_SKIP_NAMESPACE` in your `settings.py`. Example:
[source,python]
----
API_LOGGER_SKIP_NAMESPACE = ['APP_NAMESPACE1', 'APP_NAMESPACE2']
----
=== Hide Sensitive Data From Logs
To prevent sensitive information from appearing in the logs, configure `API_LOGGER_EXCLUDE_KEYS` in your `settings.py` with a list of sensitive keys. By default, the following keys are excluded:
[source,python]
----
API_LOGGER_EXCLUDE_KEYS = ['password', 'token', 'access', 'refresh']
# Sensitive data will be replaced with "***FILTERED***".
----
.Table Contributors
|===
|Name |Role |Email
|Daniel Ale |SA |d.ale@capitalsage.ng
|Isaiah Aimiton |BE |i.aimiton@capitalsage.ng
|===
[quote]
____
Happy Coding
____
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pykolofinance-1.0.3.tar.gz
(11.7 kB
view details)
Built Distribution
File details
Details for the file pykolofinance-1.0.3.tar.gz
.
File metadata
- Download URL: pykolofinance-1.0.3.tar.gz
- Upload date:
- Size: 11.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.8 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0e14f8d440de6c3a878c2678bde757d418161738a6402b8861e001cdf628e3fb |
|
MD5 | 42ef884959533c9799b52fb84dcfa96f |
|
BLAKE2b-256 | 3d51965adda67650dd0fe7ca30aa924d65b591050e51da2173c99ce4feb7f685 |
File details
Details for the file pykolofinance-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: pykolofinance-1.0.3-py3-none-any.whl
- Upload date:
- Size: 13.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.8 Darwin/23.5.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f660a6d3d7e14da23ed5eda5f69b70dad20854a492818847fd36a3b3bc88686b |
|
MD5 | d1ce71b307d14774009c4e0d0cfd9bd8 |
|
BLAKE2b-256 | fc8e7ed069326c49bc109e6b85f3d4c88a21da71cdef9464d90506672d61f691 |