git-credential-kasi (934B)
1 #!/bin/sh 2 # reads git's request on stdin and prints credentials to stdout 3 # this script is made for overleaf's non-standard ssh-less git 4 # but it can be trivially modified for other git http auth 5 6 # Setup: 7 # git config --global credential.helper kasi 8 # git config --global credential.https://git.overleaf.com/.username git 9 10 set -euo pipefail 11 12 # read the command from Git 13 if [ -n "$1" ]; then cmd="$1"; else read cmd || exit 1; fi 14 15 case "$cmd" in 16 # easier on me to manually handle credentials 17 store) ;; 18 erase) ;; 19 20 # git is fine with nothing responded to this 21 capability*) ;; 22 23 # the only command needed 24 get) 25 host="$(awk -F'=' '/^host=/ {print $2; exit}' <&0)" 26 [ "$host" != "git.overleaf.com" ] && exit 0 27 28 password="$(kasi view 'university/overleaf' | awk '/^Git:/ {print $2}')" 29 echo "username=git" 30 echo "password=$password" 31 ;; 32 *) 33 echo >&2 "Unknown command received by git-credential-kasi: $cmd" 34 exit 1 35 ;; 36 esac