Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

https interface for user management #648

Open
wants to merge 21 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
use POST for form data
  • Loading branch information
nanda committed Mar 27, 2021
commit c008010b08726882fa3d1ff3076c8af9261197dc
17 changes: 14 additions & 3 deletions lighttpd/htdocs/defs
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,26 @@ END='</body></html>'

function urldecode() { : "${*//+/ }"; echo -e "${_//%/\\x}"; }

parse_arg()

parse_get_arg()
{
while IFS='=' read -r -d '&' var val; do
var=$(urldecode "$var")
[ "$var" = "$1" ] && echo $(urldecode "$val") && return 0
done <<<"${QUERY_STRING}&"
done<<<"${QUERY_STRING}&"
return 1
}
export -f parse_get_arg

parse_post_arg()
{
while IFS='=' read -r -d '&' var val; do
var=$(urldecode "$var")
[ "$var" = "$1" ] && echo $(urldecode "$val") && return 0
done<<<"${POST_STRING}&"
return 1
}
export -f parse_arg
export -f parse_post_arg


. /etc/openvpn/http/easyrsa.env
10 changes: 6 additions & 4 deletions lighttpd/htdocs/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ print_user_table()
# name,begin,end,status
# ariya,Jul 21 11:15:44 2020 GMT,Jul 6 11:15:44 2023 GMT,VALID

echo '<form><table>'
echo '<form method="post"><table>'

echo '<tr><th colspan=5>Existing users</th></tr>
<tr><th>Username</th><th>Valid from</th><th>Valid to</th><th>Status</th><th>Config</th></tr>'
Expand Down Expand Up @@ -52,9 +52,11 @@ MY_PATH=$(readlink -f "$BASH_SOURCE")
MYDIR=$(dirname "$MY_PATH")
. "$MYDIR/defs"

action=$(parse_arg "action")
username=$(parse_arg "username")
capassphrase=$(parse_arg "capassphrase")
read -t 5 POST_STRING

action=$(parse_post_arg "action")
username=$(parse_post_arg "username")
capassphrase=$(parse_post_arg "capassphrase")
export EASYRSA_PASSIN="pass:$capassphrase"
export EASYRSA_BATCH=1
case "$action" in
Expand Down
2 changes: 1 addition & 1 deletion lighttpd/htdocs/user_config.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ MYDIR=$(dirname "$MY_PATH")
. "$MYDIR/defs"


username=$(parse_arg username)
username=$(parse_get_arg username)
[ "$?" != 0 -o -z "$username" ] && echo -e "$HEAD\n no valid user supplied!\n$END" && exit 1

CONFIG=$(ovpn_getclient "$username")
Expand Down