There is a security vulnerability in SSH key-generation using GitKraken < v8.0.1. If you used this tool to create SSH keys, please update GitKraken and regenerate. If you need help with this, contact forum-support@opengroup.org

partition_info.py 1.27 KB
Newer Older
Luc Yriarte's avatar
Luc Yriarte committed
1
2
3
4
5
6
from typing import Optional

from azure.keyvault.secrets import SecretClient

from osdu_az import conf
from osdu_az.identity.az_identity import AzureIdentity
Yannick's avatar
Yannick committed
7
8
9
10
import logging
from datetime import datetime

_LOGGER = logging.getLogger('osdu_az.storage.blob_storage_az')
Luc Yriarte's avatar
Luc Yriarte committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29


class PartitionInfo():
    def __init__(self, partition_properties: dict = None):
        self._partition_properties = partition_properties
        self._secret_client = None

    def get_value(self, property_name: str) -> Optional[str]:
        partition_property = self._partition_properties.get(property_name)
        if not partition_property:
            return None

        if not partition_property.get('sensitive'):
            return partition_property['value']

        secret = self._get_secret(partition_property['value'])
        return secret.value

    def _get_secret(self, key: str):
Yannick's avatar
Yannick committed
30
31
32
33
        ts = datetime.utcnow()
        secret = self._get_secret_client().get_secret(key)
        _LOGGER.info(f'PartitionInfo get secret took {(datetime.utcnow() - ts).total_seconds()} ms')
        return secret
Luc Yriarte's avatar
Luc Yriarte committed
34
35
36
37

    def _get_secret_client(self):
        if not self._secret_client:
            self._secret_client = SecretClient(conf.keyvault_url, AzureIdentity.get_default_credential())
Yannick's avatar
Yannick committed
38

Luc Yriarte's avatar
Luc Yriarte committed
39
40
        return self._secret_client