From 333032f27b39b0fdaa8e389b4dd1d212e1fcf0bd Mon Sep 17 00:00:00 2001 From: erebion Date: Tue, 16 Jul 2024 21:59:33 +0200 Subject: [PATCH] add invite link script --- scripts/unhb-authentik-invite.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 scripts/unhb-authentik-invite.sh diff --git a/scripts/unhb-authentik-invite.sh b/scripts/unhb-authentik-invite.sh new file mode 100755 index 0000000..f097437 --- /dev/null +++ b/scripts/unhb-authentik-invite.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash +DATEINAMONTH=$(date --date='31 days' +%F) + +if [ ! -f "authentik-api-invite.token" ]; then echo "ERROR - authentik-api.token does not exist, please save the API token to that file" && exit 1; fi +BEARERTOKEN=$(cat authentik-api-invite.token) +if [ -z ${1+x} ]; then echo "ERROR - Invite Token has no name. Spaces and special characters are not allowed. Example: ./unhb-authentik-invite.sh invite_for_jon_doe" && exit 1; fi + +echo "INFO - Generating invite link for: $1" + +LINK=$(curl --silent -X POST "https://auth.un-hack-bar.de/api/v3/stages/invitation/invitations/" \ + -H "accept: application/json"\ + -H "authorization: Bearer $BEARERTOKEN"\ + -H "content-type: application/json" \ + -d '{"name":"'$1'","expires":"'$DATEINAMONTH'T00:00:00.000Z","fixed_data":{},"single_use":true,"flow":"6a0afde87a4e40a3b3bb2215de9c34f0"}' | jq ".pk" -r 2>/dev/null | xargs -I {} -n 1 -0 echo 'https://auth.un-hack-bar.de/if/flow/unhb-invite-enrollment/?itoken={}') + +echo $LINK | qrencode -m 2 -t utf8 +echo $LINK