#!/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