2021-02-15 01:03:38 -05:00
|
|
|
#!/usr/bin/env sh
|
2023-10-10 11:20:40 -04:00
|
|
|
source /etc/openvpn/scripts/.env
|
2021-02-15 01:03:38 -05:00
|
|
|
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)
|
2021-02-15 01:03:38 -05:00
|
|
|
|
2022-07-21 11:17:53 -04:00
|
|
|
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
|
2021-02-15 01:03:38 -05:00
|
|
|
else
|
2022-12-30 09:25:21 -05:00
|
|
|
echo "$(date) Authorization for user $common_name failed"
|
2021-02-15 01:03:38 -05:00
|
|
|
exit 1
|
2022-07-21 11:17:53 -04:00
|
|
|
fi
|