diff --git a/vault_oidc_ssh_cert_action.py b/vault_oidc_ssh_cert_action.py index ddfd423..772f0f2 100644 --- a/vault_oidc_ssh_cert_action.py +++ b/vault_oidc_ssh_cert_action.py @@ -37,8 +37,12 @@ def _issue_vault_token( login_url = f"{vault_server}/v1/auth/{oidc_backend}/login" payload = {"jwt": jwt_token, "role": oidc_role} - response = requests.post(login_url, data=payload, timeout=10) - response.raise_for_status() + try: + response = requests.post(login_url, data=payload, timeout=10) + response.raise_for_status() + except requests.exceptions.HTTPError as http_error: + print(f"::error title=LoginError::{str(http_error)}") + raise VoscaError from http_error vault_token: str = response.json()["auth"]["client_token"] return vault_token @@ -66,14 +70,9 @@ def github_vault_auth() -> None: jwt_aud: str = _determine_audience(input_audience, vault_server) jwt_token: str = _issue_github_jwt(jwt_aud) - - try: - vault_token: str = _issue_vault_token( - vault_server, oidc_backend, oidc_role, jwt_token - ) - except requests.exceptions.HTTPError as http_error: - print(http_error.response.json()) - raise VoscaError from http_error + vault_token: str = _issue_vault_token( + vault_server, oidc_backend, oidc_role, jwt_token + ) print(f"::add-mask::{vault_token}") with open(os.environ["GITHUB_OUTPUT"], mode="a", encoding="utf-8") as ghof: