Skip to main content

A utility package for kolomoni 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

  1. Add pykolofinance to installed apps in django
  2. 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']

=== Exclude http request methods from being logged ?(Optional)

You can exclude selected https methods by specifying API_LOGGER_EXCLUDE_HTTP_METHODS in settings.py. By default all GET request are excluded from being logged [source,python]

API_LOGGER_EXCLUDE_HTTP_METHODS = ['GET', 'PATCH']

=== 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".


= KYC

== 1. Verification

The service includes a KYC verification service. There are three verification types:

. BVN . NIN . BVN_SELFIE

We currently have two providers:

. MOCK . DOJAH

By default, the provider is set to MOCK. To override the default value, set PYKOLO_DEFAULT_IDENTITY_SERVICE in your settings file to your preferred provider:

[source,python]

PYKOLO_DEFAULT_IDENTITY_SERVICE = "DOJAH"

Please note that when you switch the provider to DOJAH, you are required to set DOJAH_API_URL, DOJAH_APP_ID, and DOJAH_API_KEY in your settings.py file. Please note that the DOJAH API URL must be without a trailing slash /.

[source,python]

from pykolofinance.kyc.verifier import get_identity_data

identity_data = get_identity_data(identity_type, identity_number, image=None, user_id=None)

Note that an image is required while verifying BVN_SELFIE.

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

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pykolofinance-8.0.0-py3-none-any.whl (39.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pykolofinance-8.0.0.tar.gz
  • Upload date:
  • Size: 28.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pykolofinance-8.0.0.tar.gz
Algorithm Hash digest
SHA256 84064ce6d4556a5e7018e55a8ff76e67f890aa3420878747a8d8b59d526132bd
MD5 d69f4bc5901d796ef21f1959ab1626f9
BLAKE2b-256 a24cb982c86af26dc0b277c8fdc265b1eee0d5e3227e71bc010fa9f733711417

See more details on using hashes here.

File details

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

File metadata

  • Download URL: pykolofinance-8.0.0-py3-none-any.whl
  • Upload date:
  • Size: 39.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.11.4 {"installer":{"name":"uv","version":"0.11.4","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for pykolofinance-8.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 aa5a76625b5925438e1477eb66d8b876971212e2b7b0a4a713d348f00d16b569
MD5 d1c1a5fedcae23beea6d766dd8ed3822
BLAKE2b-256 42fa064279e3d26ef248e1d09ba3eb70c3bb8c82bb6e2ee9a05b19a646bc0586

See more details on using hashes here.

Supported by

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