Skip to main content

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


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.6.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

pykolofinance-1.0.6-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file pykolofinance-1.0.6.tar.gz.

File metadata

  • Download URL: pykolofinance-1.0.6.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.11.8 Darwin/23.5.0

File hashes

Hashes for pykolofinance-1.0.6.tar.gz
Algorithm Hash digest
SHA256 8717ee71074e89c15abfd2989187ca548b5b783283ce18dac1ce57bcd7ab200e
MD5 880b20885586ff0e77159e652cb0ffa5
BLAKE2b-256 522cc91bf3fc8dbb558d8b0c8070e0868a59dc0d9f74c2101c8113b6ad9fcaf9

See more details on using hashes here.

File details

Details for the file pykolofinance-1.0.6-py3-none-any.whl.

File metadata

  • Download URL: pykolofinance-1.0.6-py3-none-any.whl
  • Upload date:
  • Size: 13.9 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

Hashes for pykolofinance-1.0.6-py3-none-any.whl
Algorithm Hash digest
SHA256 6d166647e75f7ae32252795aec0d07dc9e480d7e824bbea6e8e3b870c8dd7a33
MD5 db00fab0e12938fb21b960d7ef9b23cb
BLAKE2b-256 7c3d5c5e13e7b4ed46b98c7f4809359f10a3ac61a791687a9f808a4e204632d7

See more details on using hashes here.

Supported by

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