Initial commit: git-hangman-lab and keycloak-hangman-lab skills
This commit is contained in:
28
git-hangman-lab/scripts/git/check-git-cred
Executable file
28
git-hangman-lab/scripts/git/check-git-cred
Executable file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
GIT_URL="https://git.hangman-lab.top"
|
||||
|
||||
USER="$(pass_mgr get-username --key git)"
|
||||
PASS="$(pass_mgr get-secret --key git)"
|
||||
|
||||
if [[ -z "$USER" || -z "$PASS" ]]; then
|
||||
echo "Missing credentials from pass_mgr (key: git)"
|
||||
exit 2
|
||||
fi
|
||||
|
||||
response=$(curl -s -w "%{http_code}" -u "$USER:$PASS" "$GIT_URL/api/v1/user")
|
||||
http_code="${response: -3}"
|
||||
body="${response:0:-3}"
|
||||
|
||||
if [[ "$http_code" == "200" ]]; then
|
||||
echo "OK"
|
||||
exit 0
|
||||
elif [[ "$http_code" == "401" ]]; then
|
||||
echo "AUTH FAILED"
|
||||
exit 1
|
||||
else
|
||||
echo "ERROR: HTTP $http_code"
|
||||
echo "$body"
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user