webbuild: also manage user for authentication
This commit is contained in:
parent
b84e90b7db
commit
61710ad694
@ -37,8 +37,8 @@ window.onbeforeunload = function (e) {
|
|||||||
<script src="/scripts/webbuild.js"></script>
|
<script src="/scripts/webbuild.js"></script>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
<!--
|
<!--
|
||||||
var user = "silvan";
|
var user = "";
|
||||||
var user_email = "silvan.calarco@mambasoft.it";
|
var user_email = "";
|
||||||
var secret = "";
|
var secret = "";
|
||||||
var lastupdate = 0;
|
var lastupdate = 0;
|
||||||
var reloadtime = 15000;
|
var reloadtime = 15000;
|
||||||
@ -91,8 +91,12 @@ function editorChanged() {
|
|||||||
function ajax_getvalues(request,confirm) {
|
function ajax_getvalues(request,confirm) {
|
||||||
var url = "/cgi-bin/webbuild"
|
var url = "/cgi-bin/webbuild"
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
user=getCookie("webbuild-user");
|
||||||
|
}
|
||||||
|
|
||||||
if (!secret) {
|
if (!secret) {
|
||||||
secret=getCookie("webbuild");
|
secret=getCookie("webbuild-secret");
|
||||||
}
|
}
|
||||||
if (confirm) {
|
if (confirm) {
|
||||||
document.getElementById("status").innerHTML =
|
document.getElementById("status").innerHTML =
|
||||||
@ -136,8 +140,10 @@ function ajax_getvalues(request,confirm) {
|
|||||||
for (var i = 0; i < nodes.length; i++) {
|
for (var i = 0; i < nodes.length; i++) {
|
||||||
if (nodes[i].nodeName == "title") {
|
if (nodes[i].nodeName == "title") {
|
||||||
document.title = nodes[i].childNodes[0].nodeValue;
|
document.title = nodes[i].childNodes[0].nodeValue;
|
||||||
} else if (nodes[i].nodeName == "cookie") {
|
} else if (nodes[i].nodeName == "cookie-user") {
|
||||||
setCookie("webbuild", nodes[i].childNodes[0].nodeValue, 1);
|
setCookie("webbuild-user", nodes[i].childNodes[0].nodeValue, 1);
|
||||||
|
} else if (nodes[i].nodeName == "cookie-secret") {
|
||||||
|
setCookie("webbuild-secret", nodes[i].childNodes[0].nodeValue, 1);
|
||||||
} else if (document.getElementById(nodes[i].nodeName) != undefined) {
|
} else if (document.getElementById(nodes[i].nodeName) != undefined) {
|
||||||
$("#"+nodes[i].nodeName).html(nodes[i].childNodes[0].nodeValue);
|
$("#"+nodes[i].nodeName).html(nodes[i].childNodes[0].nodeValue);
|
||||||
spectext = document.getElementById("spectext");
|
spectext = document.getElementById("spectext");
|
||||||
|
@ -37,33 +37,25 @@ if [ "$USER" ]; then
|
|||||||
USER_ENABLED=
|
USER_ENABLED=
|
||||||
if [ "$SECRET" = "$USER_SECRET" ]; then
|
if [ "$SECRET" = "$USER_SECRET" ]; then
|
||||||
USER_ENABLED=1
|
USER_ENABLED=1
|
||||||
elif [ ! "$SECRET" ]; then
|
|
||||||
USER_ENABLED=
|
|
||||||
elif [ "$USER_SECRET" ]; then
|
|
||||||
echo -n "<environments> </environments>"
|
|
||||||
echo -n "<speccreate> </speccreate>"
|
|
||||||
echo -n "<specedit> </specedit>"
|
|
||||||
echo -n "<repositories> </repositories>"
|
|
||||||
echo -n "<packages> </packages>"
|
|
||||||
echo -n "<editcontrols> </editcontrols>"
|
|
||||||
echo -n "<editor> </editor>"
|
|
||||||
echo -n "<output>Unauthorized! If this happened after you changed your password in openmamba website please ask the maintainer to be re-enabled to use this service. Thank you."
|
|
||||||
echo -n "</output>"
|
|
||||||
echo -n "<operationpanel> </operationpanel>"
|
|
||||||
echo -n "</webbuild>"
|
|
||||||
exit
|
|
||||||
elif [ "$REQUEST" = "password" ]; then
|
elif [ "$REQUEST" = "password" ]; then
|
||||||
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null
|
if [ "$USER_SECRET" ]; then
|
||||||
|
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$USER_SECRET" 2>/dev/null
|
||||||
|
else
|
||||||
|
/usr/libexec/webbuild-checkpassword "$PASSWORD" "$SECRET" 2>/dev/null
|
||||||
|
fi
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
tmpfile=`mktemp --suffix=webbuildtmp`
|
if [ ! "$USER_SECRET" ]; then
|
||||||
cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile
|
tmpfile=`mktemp --suffix=webbuildtmp`
|
||||||
echo "USER_SECRET='$SECRET'" >> $tmpfile
|
cat $WEBBUILD_STATEDIR/users/$USER.conf > $tmpfile
|
||||||
|
echo "USER_SECRET='$SECRET'" >> $tmpfile
|
||||||
|
$SUDO_WRAPPER 0 local "$USER" "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf"
|
||||||
|
fi
|
||||||
|
SECRET="$USER_SECRET"
|
||||||
USER_ENABLED=1
|
USER_ENABLED=1
|
||||||
$SUDO_WRAPPER 0 local "$USER" "" "mv $tmpfile $WEBBUILD_STATEDIR/users/$USER.conf"
|
|
||||||
else
|
else
|
||||||
USER_ENABLED=
|
USER_ENABLED=
|
||||||
fi
|
fi
|
||||||
else
|
elif [ "$REQUEST" != "refresh" ]; then
|
||||||
# no "$USER_SECRET" set; require password
|
# no "$USER_SECRET" set; require password
|
||||||
echo -n "<output><![CDATA[Please enter your password: <input type=password id=password>"
|
echo -n "<output><![CDATA[Please enter your password: <input type=password id=password>"
|
||||||
echo -n " <input type=button value=\"Submit\" onClick="
|
echo -n " <input type=button value=\"Submit\" onClick="
|
||||||
@ -82,7 +74,25 @@ if [ "$USER" ]; then
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
elif [ "$REQUEST" != "refresh" ]; then
|
||||||
|
echo -n "<output><![CDATA[Please enter your username: <input type=text id=username>"
|
||||||
|
echo -n " <input type=button value=\"Submit\" onClick="
|
||||||
|
echo -n "user=encodeURIComponent(getElementById('username').value);"
|
||||||
|
echo -n "ajax_getvalues(\"ENVIRONMENT=$ENVIRONMENT&REPOSITORY=$REPOSITORY&PACKAGE=$PACKAGEENCODED&"
|
||||||
|
echo -n "USER=\"+encodeURIComponent(getElementById('username').value));>"
|
||||||
|
echo -n "]]></output>"
|
||||||
|
echo -n "<environments> </environments>"
|
||||||
|
echo -n "<speccreate> </speccreate>"
|
||||||
|
echo -n "<specedit> </specedit>"
|
||||||
|
echo -n "<repositories> </repositories>"
|
||||||
|
echo -n "<packages> </packages>"
|
||||||
|
echo -n "<editcontrols> </editcontrols>"
|
||||||
|
echo -n "<editor> </editor>"
|
||||||
|
echo -n "<operationpanel> </operationpanel>"
|
||||||
|
echo -n "</webbuild>"
|
||||||
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$USER_ENABLED" != "1" ]; then
|
if [ "$USER_ENABLED" != "1" ]; then
|
||||||
echo -n "<environments> </environments>"
|
echo -n "<environments> </environments>"
|
||||||
echo -n "<speccreate> </speccreate>"
|
echo -n "<speccreate> </speccreate>"
|
||||||
@ -264,6 +274,11 @@ _EOF
|
|||||||
exit
|
exit
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# send data for cookie
|
||||||
|
if [ "$REQUEST" = "password" ]; then
|
||||||
|
echo -n "<cookie-user>$USER</cookie-user><cookie-secret>$USER_SECRET</cookie-secret>"
|
||||||
|
fi
|
||||||
|
|
||||||
# kill processes or clean log
|
# kill processes or clean log
|
||||||
if [ "$REQUEST" = "killtree" ]; then
|
if [ "$REQUEST" = "killtree" ]; then
|
||||||
killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes`
|
killline=`grep "^$KILLPID " $WEBBUILD_STATEDIR/processes`
|
||||||
|
Loading…
Reference in New Issue
Block a user