From 6573500de6ca44122cda3b11188a9f482990906b Mon Sep 17 00:00:00 2001 From: kar Date: Thu, 31 Jul 2025 11:42:27 -0400 Subject: add git credential helper for http(s) auth --- contrib/git-credential-kasi | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100755 contrib/git-credential-kasi diff --git a/contrib/git-credential-kasi b/contrib/git-credential-kasi new file mode 100755 index 0000000..794ef62 --- /dev/null +++ b/contrib/git-credential-kasi @@ -0,0 +1,36 @@ +#!/bin/sh +# reads git's request on stdin and prints credentials to stdout +# this script is made for overleaf's non-standard ssh-less git +# but it can be trivially modified for other git http auth + +# Setup: +# git config --global credential.helper kasi +# git config --global credential.https://git.overleaf.com/.username git + +set -euo pipefail + +# read the command from Git +if [ -n "$1" ]; then cmd="$1"; else read cmd || exit 1; fi + +case "$cmd" in + # easier on me to manually handle credentials + store) ;; + erase) ;; + + # git is fine with nothing responded to this + capability*) ;; + + # the only command needed + get) + host="$(awk -F'=' '/^host=/ {print $2; exit}' <&0)" + [ "$host" != "git.overleaf.com" ] && exit 0 + + password="$(kasi view 'university/overleaf' | awk '/^Git:/ {print $2}')" + echo "username=git" + echo "password=$password" + ;; + *) + echo >&2 "Unknown command received by git-credential-kasi: $cmd" + exit 1 + ;; +esac -- cgit v1.2.3