From ac50c87b89152cef7bdfa29da26f9831038ba789 Mon Sep 17 00:00:00 2001 From: Cyber Date: Wed, 19 Jun 2024 05:22:11 +0000 Subject: [PATCH] Add token validation --- enable-expire-notifs.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/enable-expire-notifs.sh b/enable-expire-notifs.sh index 082f590..b7fa48f 100755 --- a/enable-expire-notifs.sh +++ b/enable-expire-notifs.sh @@ -1,4 +1,14 @@ #!/bin/bash -[ -z "$1" ] && echo "You need to provide your api key fot this thing to work. -It is strongly advised enabling privacy mode (\`/privacy\`) for the time of execution" && exit 1 \ No newline at end of file +API_HOST="https://api.ssh.surf" +API_KEY="$1" + +[ -z $API_KEY ] && echo "You need to provide your api key fot this thing to work. +It is strongly advised enabling privacy mode (\`/privacy\`) for the time of execution" && exit 1 + +hello=$(curl -w %{http_code} -sH "x-ssh-auth: $API_KEY" $API_HOST/hello -o /dev/null) + +if [[ hello -ne 200 ]]; then + echo "token not valid, exiting" + exit 1 +fi