1
0
Fork 0
mirror of synced 2024-12-20 05:01:09 -05:00
ovpn-admin/setup/auth.sh

15 lines
389 B
Bash
Raw Normal View History

#!/usr/bin/env sh
2023-10-10 11:20:40 -04:00
source /etc/openvpn/scripts/.env
PATH=$PATH:/usr/local/bin
set -e
auth_usr=$(head -1 $1)
2022-12-30 09:25:21 -05:00
auth_secret=$(tail -1 $1)
if [ $common_name = $auth_usr ]; then
2023-10-10 11:20:40 -04:00
curl -s --fail --data-raw 'username='${auth_usr} --data-raw 'token='${auth_secret} localhost:8080${OVPN_LISTEN_BASE_URL}api/auth/check
else
2022-12-30 09:25:21 -05:00
echo "$(date) Authorization for user $common_name failed"
exit 1
fi