Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Hashicorp Vault support plus test (WIP) #506

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions repository_service_tuf_worker/repository.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
get_repository_settings,
get_worker_settings,
)
from repository_service_tuf_worker.interfaces import IKeyVault, IStorage
from repository_service_tuf_worker.interfaces import IStorage
from repository_service_tuf_worker.models import (
rstuf_db,
targets_crud,
Expand Down Expand Up @@ -168,10 +168,6 @@ def refresh_settings(self, worker_settings: Optional[Dynaconf] = None):
# storage
IStorage.from_dynaconf(settings)

# keyvault
if settings.get("KEYVAULT_BACKEND"):
IKeyVault.from_dynaconf(settings)

self._worker_settings = settings
return settings

Expand Down
4 changes: 0 additions & 4 deletions repository_service_tuf_worker/services/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,9 @@
# SPDX-License-Identifier: MIT

from repository_service_tuf_worker.interfaces import ( # noqa
IKeyVault,
IStorage,
ServiceSettings,
)
from repository_service_tuf_worker.services.keyvault.local import ( # noqa
LocalKeyVault,
)
from repository_service_tuf_worker.services.storage import ( # noqa
AWSS3,
LocalStorage,
Expand Down
4 changes: 0 additions & 4 deletions repository_service_tuf_worker/services/keyvault/__init__.py

This file was deleted.

214 changes: 0 additions & 214 deletions repository_service_tuf_worker/services/keyvault/local.py

This file was deleted.

6 changes: 3 additions & 3 deletions repository_service_tuf_worker/signer.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,7 @@ def from_priv_key_uri(

RSTUF_ONLINE_KEY_URI_FIELD = "x-rstuf-online-key-uri"

# Register non-default securesystemslib file signer
# secure-systems-lab/securesystemslib#617
SIGNER_FOR_URI_SCHEME[CryptoSigner.FILE_URI_SCHEME] = CryptoSigner

# Register custom FileNameSigner
SIGNER_FOR_URI_SCHEME[FileNameSigner.SCHEME] = FileNameSigner

Expand All @@ -101,6 +99,8 @@ def isolated_env(env: dict[str, str]):
"AWS_SECRET_ACCESS_KEY",
"AWS_ENDPOINT_URL",
"AWS_DEFAULT_REGION",
"VAULT_ADDR",
"VAULT_TOKEN",
]


Expand Down
4 changes: 2 additions & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,10 @@ pydantic-core==2.18.2; python_version >= '3.8'
pynacl==1.5.0
pytz==2024.1
redis==5.0.4; python_version >= '3.7'
securesystemslib[crypto,pynacl]==0.31.0; python_version ~= '3.8'
securesystemslib[crypto]==1.0.0; python_version ~= '3.8'
sqlalchemy==2.0.29; python_version >= '3.7'
supervisor==4.2.5
tuf==4.0.0; python_version >= '3.8'
tuf @ git+https://github.com/theupdateframework/python-tuf@a7b832b88ff3c094aafdd78a72bbcf19a93b0bf0 ; python_version >= '3.8'
tzdata==2024.1; python_version >= '2'
vine==5.1.0; python_version >= '3.6'
watchdog==4.0.0; python_version >= '3.8'
Expand Down
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ pytz==2024.1
redis==5.0.4; python_version >= '3.7'
requests==2.31.0; python_version >= '3.7'
s3transfer==0.10.1; python_version >= '3.8'
securesystemslib[crypto,pynacl]==0.31.0; python_version ~= '3.8'
securesystemslib[crypto]==1.0.0; python_version ~= '3.8'
setuptools==69.5.1; python_version >= '3.8'
six==1.16.0; python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3'
sqlalchemy==2.0.29; python_version >= '3.7'
supervisor==4.2.5
tuf==4.0.0; python_version >= '3.8'
tuf @ git+https://github.com/theupdateframework/python-tuf@a7b832b88ff3c094aafdd78a72bbcf19a93b0bf0 ; python_version >= '3.8'
typing-extensions==4.11.0; python_version >= '3.8'
tzdata==2024.1; python_version >= '2'
urllib3==2.2.1; python_version >= '3.10'
Expand Down
13 changes: 13 additions & 0 deletions tests/files/vault/init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

vault server -dev -dev-root-token-id="${RSTUF_VAULT_TOKEN}" &

export VAULT_ADDR=${RSTUF_VAULT_ADDR}

until vault status
do
sleep 0.1
done

vault secrets enable transit
vault write -force transit/keys/test-key-ed25519 type=ed25519
3 changes: 3 additions & 0 deletions tests/files/vault/stop.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

pkill -f "vault server -dev"
8 changes: 0 additions & 8 deletions tests/unit/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,6 @@

@pytest.fixture()
def test_repo(monkeypatch: pytest.MonkeyPatch) -> MetadataRepository:
from repository_service_tuf_worker.services.keyvault import local

fake_import_privatekey_from_file = pretend.call_recorder(lambda *a: None)
monkeypatch.setattr(
local,
"import_privatekey_from_file",
fake_import_privatekey_from_file,
)
return MetadataRepository.create_service()


Expand Down
Loading
Loading