generated from ghga-de/microservice-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update lock files and template files * Bump version from 1.3.1 -> 1.4.0 Update lock files, openapi, config, readme Add vault config to sms config * Add secrets handler to sms * Add unit tests for sms vault * Log InvalidPath error but don't re-raise Remove custom errors -- are not used * Add integration tests and vault fixture * Add unit tests for the SecretsHandler * Remove VaultFixture.get_secret() * Make vault container persistent for tests Compartmentalize VaultConfig * Update config to use sms instead of ekss * Only offer mass deletion endpoint * Move vault_path from config to API * Delete unused dummy test functionality and a test * Rename vault fixture to remove pragmas * Remove dummy secrets handler, just use mock
- Loading branch information
1 parent
0802680
commit e1d98e8
Showing
25 changed files
with
2,184 additions
and
1,277 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# Copyright 2021 - 2024 Universität Tübingen, DKFZ, EMBL, and Universität zu Köln | ||
# for the German Human Genome-Phenome Archive (GHGA) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""FastAPI routes for HashiCorp Vault state management.""" | ||
|
||
from typing import Annotated | ||
|
||
from fastapi import APIRouter, HTTPException, status | ||
from pydantic import Field | ||
|
||
from sms.adapters.inbound.fastapi_ import dummies | ||
from sms.adapters.inbound.fastapi_.http_authorization import ( | ||
TokenAuthContext, | ||
require_token, | ||
) | ||
|
||
secrets_router = APIRouter() | ||
|
||
vault_path_field = Field( | ||
default=..., description="The path to the vault", examples=["ekss", "sms"] | ||
) | ||
|
||
|
||
@secrets_router.get( | ||
"/{vault_path}", | ||
operation_id="get_secrets", | ||
summary="Returns a list of secrets in the vault", | ||
status_code=status.HTTP_200_OK, | ||
response_model=list[str], | ||
) | ||
async def get_secrets( | ||
secrets_handler: dummies.SecretsHandlerPortDummy, | ||
_token: Annotated[TokenAuthContext, require_token], | ||
vault_path: Annotated[str, vault_path_field], | ||
): | ||
"""Returns a list of secrets in the specified vault""" | ||
try: | ||
return secrets_handler.get_secrets(vault_path) | ||
except Exception as exc: | ||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) from exc | ||
|
||
|
||
@secrets_router.delete( | ||
"/{vault_path}", | ||
operation_id="delete_secrets", | ||
summary="""Delete all secrets from the specified vault.""", | ||
status_code=status.HTTP_204_NO_CONTENT, | ||
) | ||
async def delete_secrets( | ||
secrets_handler: dummies.SecretsHandlerPortDummy, | ||
_token: Annotated[TokenAuthContext, require_token], | ||
vault_path: Annotated[str, vault_path_field], | ||
): | ||
"""Delete all secrets from the specified vault.""" | ||
try: | ||
secrets_handler.delete_secrets(vault_path) | ||
except Exception as exc: | ||
raise HTTPException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR) from exc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.