This PR introduces the ability to optionally provide username and password for OpenVPN connections that require user authentication. If these fields are not provided, OpenVPN will still run without the --auth-user-pass option, ensuring compatibility with configurations that do not require user credentials.
Changes:
config.json Updates:
Added username and password fields to the configuration schema, allowing users to optionally input their VPN credentials via the Home Assistant UI.
Create an auth.txt file containing the credentials only if both username and password are provided.
Add the --auth-user-pass option to the OpenVPN command when credentials are provided.
Run OpenVPN without the --auth-user-pass option if credentials are not supplied, allowing it to function with configurations that don’t require authentication.
if [[ -n "$USERNAME" ]] && [[ -n "$PASSWORD" ]]; then
echo "$USERNAME" > $AUTH_FILE
echo "$PASSWORD" >> $AUTH_FILE
AUTH_OPTION="--auth-user-pass $AUTH_FILE"
else
AUTH_OPTION=""
fi
openvpn --config ${OPENVPN_CONFIG} $AUTH_OPTION
Impact:
These changes provide flexibility to users who either have VPN configurations that require authentication via username and password or those who do not.
If the username and password fields are left blank, OpenVPN will proceed without the need for credentials.
Description:
This PR introduces the ability to optionally provide
username
andpassword
for OpenVPN connections that require user authentication. If these fields are not provided, OpenVPN will still run without the--auth-user-pass
option, ensuring compatibility with configurations that do not require user credentials.Changes:
config.json
Updates:username
andpassword
fields to the configuration schema, allowing users to optionally input their VPN credentials via the Home Assistant UI.run.sh
Updates:run.sh
script to:username
andpassword
are provided.auth.txt
file containing the credentials only if bothusername
andpassword
are provided.--auth-user-pass
option to the OpenVPN command when credentials are provided.--auth-user-pass
option if credentials are not supplied, allowing it to function with configurations that don’t require authentication.openvpn --config ${OPENVPN_CONFIG} $AUTH_OPTION
Impact:
username
andpassword
or those who do not.username
andpassword
fields are left blank, OpenVPN will proceed without the need for credentials.