This is an automated email from the ASF dual-hosted git repository.
ephraimanierobi pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airflow.git
The following commit(s) were added to refs/heads/main by this push:
new 9ba09f3e072 Add HTTP URL authentication support to GitHook (#58194)
9ba09f3e072 is described below
commit 9ba09f3e07206bfcef7c9b6fff80b7185999a61e
Author: Ephraim Anierobi <[email protected]>
AuthorDate: Tue Nov 11 15:53:58 2025 +0100
Add HTTP URL authentication support to GitHook (#58194)
GitHook now supports authentication tokens with HTTP URLs, matching
the existing HTTPS support. This enables authentication with internal
git repositories that use HTTP instead of HTTPS.
HTTP URLs without authentication tokens are preserved as-is.
---
.../git/src/airflow/providers/git/hooks/git.py | 5 ++++
providers/git/tests/unit/git/hooks/test_git.py | 30 ++++++++++++++++++++++
2 files changed, 35 insertions(+)
diff --git a/providers/git/src/airflow/providers/git/hooks/git.py
b/providers/git/src/airflow/providers/git/hooks/git.py
index 60964fe9f4d..d0941811cb5 100644
--- a/providers/git/src/airflow/providers/git/hooks/git.py
+++ b/providers/git/src/airflow/providers/git/hooks/git.py
@@ -91,6 +91,11 @@ class GitHook(BaseHook):
return
if self.auth_token and self.repo_url.startswith("https://"):
self.repo_url = self.repo_url.replace("https://",
f"https://{self.user_name}:{self.auth_token}@")
+ elif self.auth_token and self.repo_url.startswith("http://"):
+ self.repo_url = self.repo_url.replace("http://",
f"http://{self.user_name}:{self.auth_token}@")
+ elif self.repo_url.startswith("http://"):
+ # if no auth token, use the repo url as is
+ self.repo_url = self.repo_url
elif not self.repo_url.startswith("git@") or not
self.repo_url.startswith("https://"):
self.repo_url = os.path.expanduser(self.repo_url)
diff --git a/providers/git/tests/unit/git/hooks/test_git.py
b/providers/git/tests/unit/git/hooks/test_git.py
index 3f96f0c9dff..1137d199581 100644
--- a/providers/git/tests/unit/git/hooks/test_git.py
+++ b/providers/git/tests/unit/git/hooks/test_git.py
@@ -38,10 +38,13 @@ def bundle_temp_dir(tmp_path):
GIT_DEFAULT_BRANCH = "main"
AIRFLOW_HTTPS_URL = "https://github.com/apache/airflow.git"
+AIRFLOW_HTTP_URL = "http://github.com/apache/airflow.git"
AIRFLOW_GIT = "[email protected]:apache/airflow.git"
ACCESS_TOKEN = "my_access_token"
CONN_DEFAULT = "git_default"
CONN_HTTPS = "my_git_conn"
+CONN_HTTP = "my_git_conn_http"
+CONN_HTTP_NO_AUTH = "my_git_conn_http_no_auth"
CONN_ONLY_PATH = "my_git_conn_only_path"
CONN_ONLY_INLINE_KEY = "my_git_conn_only_inline_key"
CONN_BOTH_PATH_INLINE = "my_git_conn_both_path_inline"
@@ -85,6 +88,21 @@ class TestGitHook:
conn_type="git",
)
)
+ create_connection_without_db(
+ Connection(
+ conn_id=CONN_HTTP,
+ host=AIRFLOW_HTTP_URL,
+ password=ACCESS_TOKEN,
+ conn_type="git",
+ )
+ )
+ create_connection_without_db(
+ Connection(
+ conn_id=CONN_HTTP_NO_AUTH,
+ host=AIRFLOW_HTTP_URL,
+ conn_type="git",
+ )
+ )
create_connection_without_db(
Connection(
conn_id=CONN_ONLY_PATH,
@@ -113,6 +131,18 @@ class TestGitHook:
{"repo_url": "https://github.com/apache/zzzairflow"},
f"https://user:{ACCESS_TOKEN}@github.com/apache/zzzairflow",
),
+ (CONN_HTTP, {},
f"http://user:{ACCESS_TOKEN}@github.com/apache/airflow.git"),
+ (
+ CONN_HTTP,
+ {"repo_url": "http://github.com/apache/zzzairflow"},
+ f"http://user:{ACCESS_TOKEN}@github.com/apache/zzzairflow",
+ ),
+ (CONN_HTTP_NO_AUTH, {}, AIRFLOW_HTTP_URL),
+ (
+ CONN_HTTP_NO_AUTH,
+ {"repo_url": "http://github.com/apache/zzzairflow"},
+ "http://github.com/apache/zzzairflow",
+ ),
(CONN_ONLY_PATH, {}, "path/to/repo"),
],
)