blob: 794ef624d72d4f928c153ddc3594d141361b7e8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
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
|