summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xcontrib/git-credential-kasi36
1 files changed, 36 insertions, 0 deletions
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 @@
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
10set -euo pipefail
11
12# read the command from Git
13if [ -n "$1" ]; then cmd="$1"; else read cmd || exit 1; fi
14
15case "$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 ;;
36esac