Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.toolbox
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Gabriel Monnerat
slapos.toolbox
Commits
efad6d9c
Commit
efad6d9c
authored
Feb 10, 2014
by
Nicolas Wavrant
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
runner: can now add several users to .htpasswd
parent
4cb5acdf
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
84 additions
and
4 deletions
+84
-4
slapos/runner/static/js/scripts/account.js
slapos/runner/static/js/scripts/account.js
+38
-0
slapos/runner/templates/account.html
slapos/runner/templates/account.html
+21
-3
slapos/runner/utils.py
slapos/runner/utils.py
+10
-0
slapos/runner/views.py
slapos/runner/views.py
+15
-1
No files found.
slapos/runner/static/js/scripts/account.js
View file @
efad6d9c
...
...
@@ -95,4 +95,42 @@ $(document).ready(function () {
});
return
false
;
});
$
(
"
#add_user
"
).
click
(
function
()
{
if
(
$
(
"
input#new_username
"
).
val
()
===
""
||
!
$
(
"
input#new_username
"
).
val
().
match
(
/^
[\w\d\.
_
\-]
+$/
))
{
$
(
"
#error
"
).
Popup
(
"
Invalid user name. Please check it!
"
,
{
type
:
'
alert
'
,
duration
:
3000
});
return
false
;
}
if
(
!
$
(
"
input#new_rcode
"
).
val
().
match
(
/^
[\w\d]
+$/
))
{
$
(
"
#error
"
).
Popup
(
"
Please enter your password recovery code.
"
,
{
type
:
'
alert
'
,
duration
:
3000
});
return
false
;
}
if
(
send
)
{
return
false
;
}
send
=
true
;
$
.
ajax
({
type
:
"
POST
"
,
url
:
$SCRIPT_ROOT
+
'
/addUser
'
,
data
:
{
username
:
$
(
"
input#new_username
"
).
val
(),
password
:
$
(
"
input#new_password
"
).
val
(),
rcode
:
$
(
"
input#new_rcode
"
).
val
(),
},
success
:
function
(
data
)
{
if
(
data
.
code
===
1
)
{
$
(
"
#error
"
).
Popup
(
data
.
result
,
{
type
:
'
info
'
,
duration
:
5000
});
}
else
if
(
data
.
code
===
0
)
{
$
(
"
#error
"
).
Popup
(
data
.
result
,
{
type
:
'
error
'
,
duration
:
5000
});
}
else
{
$
(
"
#error
"
).
Popup
(
data
.
result
,
{
type
:
'
alert
'
,
duration
:
5000
});
}
send
=
false
;
$
(
"
input#new_username
"
).
val
(
''
);
$
(
"
input#new_password
"
).
val
(
''
);
$
(
"
input#new_rcode
"
).
val
(
''
);
},
error
:
function
()
{
send
=
false
;
}
});
return
false
;
});
});
slapos/runner/templates/account.html
View file @
efad6d9c
...
...
@@ -13,8 +13,8 @@
<li><a
href=
"#tab1"
class=
"active"
>
Your personal information
</a></li>
{% if params %}
<li><a
href=
"#tab2"
>
Build
&
Run configuration
</a></li>
<li><a
href=
"#tab3"
>
Add user
</a></li>
{% endif %}
<!--<li><a href="#tab3">Configurations</a></li>-->
</ul>
<!-- //Tab buttons -->
<div
class=
"tabDetails"
>
<div
id=
"tab1"
class=
"tabContents"
>
...
...
@@ -73,9 +73,27 @@
</div>
</form>
</div>
<div
id=
"tab3"
class=
"tabContents"
>
<form
class=
"slapgrid"
>
<div
class=
'form'
>
<label
for=
"username"
>
New user name :
</label>
<input
type=
'text'
name=
'username'
id=
'new_username'
/>
<div
class=
'clear'
></div>
<label
for=
"password"
>
New password :
</label>
<input
type=
'password'
name=
'password'
id=
'new_password'
/>
<div
class=
'clear'
></div>
<label
for=
"new_rcode"
>
Password Recovery code:
</label>
<input
type=
'password'
name=
'new_rcode'
id=
'new_rcode'
value=
''
/>
<span
class=
"information"
><a
href=
"#"
id=
"information"
rel=
"tooltip"
>
help ?
</a></span>
<div
class=
'clear'
></div>
<br/>
<label></label>
<input
type=
"submit"
name=
"add_user"
id=
"add_user"
value=
"Add new user"
class=
"button"
/>
<div
class=
'clear'
></div>
</div>
</form>
</div>
{% endif %}
<!--<div id="tab3" class="tabContents">
</div>-->
</div>
</div>
{% if username %}
<div
id=
"file_info"
class=
"file_info"
>
leave passwords blank to preserve your current password...
...
...
slapos/runner/utils.py
View file @
efad6d9c
...
...
@@ -112,6 +112,16 @@ def saveSession(config, account):
return
str
(
e
)
def
createNewUser
(
config
,
name
,
passwd
):
htpasswdfile
=
os
.
path
.
join
(
config
[
'etc_dir'
],
'.htpasswd'
)
if
os
.
path
.
exists
(
htpasswdfile
):
htpasswd
=
HtpasswdFile
(
htpasswdfile
)
htpasswd
.
update
(
name
,
passwd
)
htpasswd
.
save
()
return
True
return
False
def
getCurrentSoftwareReleaseProfile
(
config
):
"""
Returns used Software Release profile as a string.
...
...
slapos/runner/views.py
View file @
efad6d9c
...
...
@@ -13,7 +13,8 @@ from flask import (Flask, request, redirect, url_for, render_template,
g
,
flash
,
jsonify
,
session
,
abort
,
send_file
)
from
slapos.runner.process
import
killRunningProcess
from
slapos.runner.utils
import
(
checkSoftwareFolder
,
configNewSR
,
getProfilePath
,
from
slapos.runner.utils
import
(
checkSoftwareFolder
,
configNewSR
,
createNewUser
,
getProfilePath
,
listFolder
,
getBuildAndRunParams
,
getProjectTitle
,
getSession
,
getSlapStatus
,
getSvcStatus
,
...
...
@@ -599,6 +600,18 @@ def configAccount():
else
:
return
jsonify
(
code
=
1
,
result
=
""
)
def
addUser
():
code
=
request
.
form
[
'rcode'
].
strip
()
recovery_code
=
open
(
os
.
path
.
join
(
app
.
config
[
'etc_dir'
],
".rcode"
),
"r"
).
read
().
strip
()
if
code
!=
recovery_code
:
return
jsonify
(
code
=
0
,
result
=
"Your password recovery code is not valid!"
)
if
createNewUser
(
app
.
config
,
request
.
form
[
'username'
],
request
.
form
[
'password'
]):
return
jsonify
(
code
=
1
,
result
=
"New user succesfully saved"
)
else
:
return
jsonify
(
code
=
0
,
result
=
"Problem while creating new user"
)
#Global File Manager
def
fileBrowser
():
...
...
@@ -769,3 +782,4 @@ app.add_url_rule("/fileBrowser", 'fileBrowser', fileBrowser,
app
.
add_url_rule
(
"/editFile"
,
'editFile'
,
editFile
,
methods
=
[
'GET'
])
app
.
add_url_rule
(
'/shell'
,
'shell'
,
shell
)
app
.
add_url_rule
(
'/isSRReady'
,
'isSRReady'
,
isSRReady
)
app
.
add_url_rule
(
'/addUser'
,
'addUser'
,
addUser
,
methods
=
[
'POST'
])
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment