Auth module is one of the CBD3 python packages.

Provides functionality for authorization.

Development guide

Auth file

CBD3 uses the auth.yml file to store broker's credentials

Structure:

{group_name}:
  {broker_name}:
    token: {encrypted_token}
    broker_info:
      legal_name:
        uk_UA: {broker_legal_name_ua}
        en_US: {broker_legal_name_en}
    ips:
      - {broker_ip}
      - {broker_ip}
    procedures:
      {procedure_type}:
        - {access_right}
        - {access_right}
      {procedure_type}:
        - {access_right}
        - {access_right}

names

  • {group_name} - name of brokers group
  • {broker_name} - name of broker

token

  • {encrypted_token} - encrypted broker's token

broker_info

  • {broker_legal_name_ua} - legal name of broker (UA lang)
  • {broker_legal_name_en} - legal name of broker (EN lang)

ips

  • {broker_ip} - broker ip/ips with access

If ips key does not exist - broker has access from any ip.

If ips: [] - broker does not have access.

procedures

  • {procedure_type} - type of procedure

    Options:

    • renewables
    • subsoil
    • timber
    • railwayCargo
  • {access_right} - access permission

    Options:

    • procedure - permission to create new procedure
    • bids - permission to create new bid and update bid status

Example:

auth.yml

brokers:
  some_broker:
    token: 123encryptedtoken123
    broker_info:
      legal_name:
        uk_UA: Якийсь Брокер
        en_US: Some Broker
    ips:
      - 255.255.255.255
      - 0.0.0.0/24
    procedures:
      renewables:
        - procedure
        - bids
      timber:
        - procedure
        - bids
      subsoil:
        - procedure
        - bids
      railwayCargo:
        - procedure
        - bids

Running module locally

System dependencies:

  • make
  • docker
  • docker-compose

To run project locally

make run

To build docker images for the project

make docker-build

To run tests

make test-integration

Add new package

To install package add it in Pipfile to package's group:

  • [packages] - for minimally required packages
  • [dev-packages] - for development-only packages (test-requirements)

If you don’t have any specific version requirements for your dependencies, you can use the wildcard character * to tell Pipenv that any version can be installed:

[packages]
numpy = "*"

If you want specify exact versions of requirements:

[packages]
numpy = "==1.14.1"

To specify greater than or equal version requirement:

[packages]
numpy = ">=1.14.1"

After adding package to Pipfile, you should update Pipfile.lock file in appropriate directory:

pipenv lock

You can set PIPENV_IGNORE_VIRTUALENVS=1 to force pipenv to ignore that environment and create its own instead with required python version.

PIPENV_IGNORE_VIRTUALENVS=1 pipenv lock --python 3.9

Pipfile.lock file enables deterministic builds by specifying the exact requirements for reproducing an environment. It contains exact versions for packages and hashes to support more secure verification. Do not update this file manually!

There are two sources for packages:

If you’d like a specific package to be installed with a specific package index (e.g. from https://pypi-int.prozorro.sale/), you can do the following:

[packages]
prozorro-tools = {version="==0.14.0", index="prozorro"}

Auto Documentation

To generate sphinx docs

pip install -r requirements/docs.txt
make dev-docs
  • No labels