Skip to content

Commit 6aabd09

Browse files
Update airbyte_cdk/sources/declarative/auth/jwt.py
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 7cf2b4b commit 6aabd09

File tree

1 file changed

+13
-13
lines changed
  • airbyte_cdk/sources/declarative/auth

1 file changed

+13
-13
lines changed

airbyte_cdk/sources/declarative/auth/jwt.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -173,19 +173,19 @@ def _get_secret_key(self) -> JwtKeyTypes:
173173
secret_key: str = self._secret_key.eval(self.config, json_loads=json.loads)
174174

175175
if self._passphrase:
176-
# Load encrypted private key and cast to JWT-compatible type
177-
# The JWT algorithms we support (RSA, ECDSA, EdDSA) use compatible key types
178-
private_key = serialization.load_pem_private_key(
179-
secret_key.encode(),
180-
password=self._passphrase.eval(self.config, json_loads=json.loads).encode(),
181-
)
182-
return cast(JwtKeyTypes, private_key)
183-
else:
184-
return (
185-
base64.b64encode(secret_key.encode()).decode()
186-
if self._base64_encode_secret_key
187-
else secret_key
188-
)
176+
passphrase_value = self._passphrase.eval(self.config, json_loads=json.loads)
177+
if passphrase_value:
178+
private_key = serialization.load_pem_private_key(
179+
secret_key.encode(),
180+
password=passphrase_value.encode(),
181+
)
182+
return cast(JwtKeyTypes, private_key)
183+
184+
return (
185+
base64.b64encode(secret_key.encode()).decode()
186+
if self._base64_encode_secret_key
187+
else secret_key
188+
)
189189

190190
def _get_signed_token(self) -> Union[str, Any]:
191191
"""

0 commit comments

Comments
 (0)