Skip to content

Шифрование учетных данных

Bases: BaseModel

Settings for encrypting & decrypting credential data stored in database.

Connecting to source and target databases, file systems and so on requires credentials to be passed. For now, SyncMaster stores all credentials in database table credentials, in encrypted form. This is done by symmetric algorithm Fernet <https://cryptography.io/en/latest/fernet/>_.

Before starting SyncMaster, generate a new key using the following example:

from cryptography.fernet import Fernet Fernet.generate_key().decode('utf-8') UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=

Examples

.. code-block:: yaml :caption: config.yml

encryption:
    secret_key: UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
Source code in syncmaster/settings/credentials.py
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class CredentialsEncryptionSettings(BaseModel):
    """Settings for encrypting & decrypting credential data stored in database.

    Connecting to source and target databases, file systems and so on requires credentials to be passed.
    For now, SyncMaster stores all credentials in database table ``credentials``, in encrypted form.
    This is done by symmetric algorithm `Fernet <https://cryptography.io/en/latest/fernet/>`_.

    Before starting SyncMaster, generate a new key using the following example:

    >>> from cryptography.fernet import Fernet
    >>> Fernet.generate_key().decode('utf-8')
    UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=

    Examples
    --------

    .. code-block:: yaml
        :caption: config.yml

        encryption:
            secret_key: UBgPTioFrtH2unlC4XFDiGf5sYfzbdSf_VgiUSaQc94=
    """

    secret_key: str = Field(
        description=textwrap.dedent(
            "Secret key for encrypting/decrypting credentials stored in database.",
        ),
    )