git-credential-sec: the token goes to https://gitea.dooplex.hu only (R-925)
gates / gates (push) Successful in 3m41s
gates / gates (push) Successful in 3m41s
The helper answered any server git asked about. It now reads protocol and host and answers one server. Test: scripts/test_git_credential_sec.py (7 cases; red-proofed, 4 fail against the old helper). Claude-Session: https://claude.ai/code/session_0159rPz1ZhFKsS53msqPYxtS
This commit is contained in:
1 parent
d4c7e84c22
commit
b79f9e1673
3 files changed
+56
No files matched your search
@@ -15,6 +15,21 @@
|
||||
# clear-text credentials file). A public repository still fetches, because the server asks for nothing.
|
||||
# The helper writes the value only to git's pipe: never to a file, the terminal or a log.
|
||||
[ "${1:-}" = get ] || exit 0
|
||||
# The token goes to ONE server only. Git writes "protocol=" and "host=" lines on the helper's input; for any other
|
||||
# server (a submodule, a redirect, a changed address) the helper says nothing and stops git from asking on.
|
||||
proto=; host=
|
||||
while IFS= read -r line; do
|
||||
case "$line" in
|
||||
protocol=*) proto=${line#protocol=} ;;
|
||||
host=*) host=${line#host=} ;;
|
||||
"") break ;;
|
||||
esac
|
||||
done
|
||||
if [ "$proto" != https ] || [ "$host" != gitea.dooplex.hu ]; then
|
||||
printf 'git-credential-sec: no credential for this server (only https://gitea.dooplex.hu)\n' >&2
|
||||
printf 'quit=true\n'
|
||||
exit 0
|
||||
fi
|
||||
if [ -z "${GITEA_GIT_TOKEN:-}" ]; then
|
||||
printf 'git-credential-sec: no token in the environment. Run: sec run GITEA_GIT_TOKEN -- git <command>\n' >&2
|
||||
printf 'quit=true\n'
|
||||
|
||||
Reference in new issue
Block a user