Skip to content
Merged
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
20 changes: 19 additions & 1 deletion airbyte_cdk/sources/declarative/interpolation/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,24 @@ def base64decode(value: str) -> str:
return base64.b64decode(value.encode("utf-8")).decode()


def base64binascii_decode(value: str) -> str:
"""
Implementation of a custom Jinja2 filter to decode base64 strings using ASCII encoding

For example:

OAuthAuthenticator:
$ref: "#/definitions/OAuthAuthenticator"
$parameters:
name: "client_id"
value: "{{ config['client_id'] | base64binascii_decode }}"

:param value: value to be decoded from base64 using ascii
:return: base64 decoded string ascii
"""
return base64.standard_b64encode(value.encode("ascii")).decode("ascii")


def string(value: Any) -> str:
"""
Converts the input value to a string.
Expand All @@ -117,5 +135,5 @@ def regex_search(value: str, regex: str) -> str:
return ""


_filters_list = [hash, base64encode, base64decode, string, regex_search]
_filters_list = [hash, base64encode, base64decode, base64binascii_decode, string, regex_search]
filters = {f.__name__: f for f in _filters_list}
Loading