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
web passwd admin cgi
  • Loading branch information
nanda committed Mar 28, 2021
commit c3688c1df05c5c37461911585f96aae8a83da672
3 changes: 3 additions & 0 deletions lighttpd/htdocs/index.cgi
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ print_user_table()
</table>
</div>
<div>* Global passphrase for the user management, can be found in keepassxc pwd db</div>
<br/>

<div><a href="web_password.cgi">Openvpn admin web (this page) access management</a>

</form>'
}
Expand Down
59 changes: 59 additions & 0 deletions lighttpd/htdocs/web_password.cgi
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash


MY_PATH=$(readlink -f "$BASH_SOURCE")
MYDIR=$(dirname "$MY_PATH")
. "$MYDIR/defs"
db="$OPENVPN/http/htpasswd"

read -t 5 POST_STRING

username=$(parse_post_arg "username")
pass=$(parse_post_arg "password")

res=-1
if [ -n "$username" ]; then
if [ -z "$pass" ]; then
openssl-htpasswd -D "$db" "$username"
res=$?
else
openssl-htpasswd "$db" "$username" "$pass"
res=$?
fi
fi

echo "$HEAD"
echo '
<h1>Openvpn admin web access config</h1>
<h2>Current user list</h2>
<p>
<ul>
'
cat "$db" | cut -d ':' -f 1 | while read un; do echo "<li>$un</li>"; done
echo '</ul></p>
<h2>User Management</h2>
<p>
<form method="post">
<table
<tr><td>Username</td>
<td><input type="text" id="username" name="username"/></td>
</tr>

<tr><td>Password*</td>
<td><input type="password" id="password" name="password"/></td>
</tr>

<tr><td colspan=2><button type="submit" onclick="done()">Set it!</button></td></tr>
</table>

</form>
</p>
<div>*use empty password to delete user</div>'

if [ "$res" != '-1' ]; then
[ "$res" = 0 ] && echo "<h2>Success</h2>" || echo "<h2>Failed</h2>"
echo "<p>(modyfiing user $username)</p>"
fi

echo "$END"