Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
slapos
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
Xavier Thompson
slapos
Commits
8e3ac372
Commit
8e3ac372
authored
Jan 15, 2021
by
Xavier Thompson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
software/jupyter: Simplify password generation
parent
ec1eba0b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
11 additions
and
121 deletions
+11
-121
software/jupyter/buildout.hash.cfg
software/jupyter/buildout.hash.cfg
+3
-7
software/jupyter/instance-jupyter.cfg.in
software/jupyter/instance-jupyter.cfg.in
+7
-17
software/jupyter/instance.cfg.in
software/jupyter/instance.cfg.in
+0
-2
software/jupyter/jupyter_notebook_config.py.jinja
software/jupyter/jupyter_notebook_config.py.jinja
+1
-28
software/jupyter/jupyter_set_password.cgi.jinja
software/jupyter/jupyter_set_password.cgi.jinja
+0
-64
software/jupyter/software.cfg
software/jupyter/software.cfg
+0
-3
No files found.
software/jupyter/buildout.hash.cfg
View file @
8e3ac372
...
@@ -15,19 +15,15 @@
...
@@ -15,19 +15,15 @@
[instance]
[instance]
filename = instance.cfg.in
filename = instance.cfg.in
md5sum =
13fcabee7821bc4cdda2f99e4190be7
3
md5sum =
f33fc954eba47b5ddbebc72c453304e
3
[instance-jupyter]
[instance-jupyter]
filename = instance-jupyter.cfg.in
filename = instance-jupyter.cfg.in
md5sum =
521d5a742d5304a6f88c000db28d6e28
md5sum =
9340498841caa5771f40f8c9e561eacd
[jupyter-notebook-config]
[jupyter-notebook-config]
filename = jupyter_notebook_config.py.jinja
filename = jupyter_notebook_config.py.jinja
md5sum = 4514df152740dbd7990da9705f40e978
md5sum = 6e01da7d35c1d65d4a450b0f011b296d
[jupyter-set-password]
filename = jupyter_set_password.cgi.jinja
md5sum = b8d31441780b524a7e52d1710dd78385
[erp5-kernel]
[erp5-kernel]
filename = ERP5kernel.py
filename = ERP5kernel.py
...
...
software/jupyter/instance-jupyter.cfg.in
View file @
8e3ac372
...
@@ -3,8 +3,6 @@
...
@@ -3,8 +3,6 @@
[buildout]
[buildout]
parts =
parts =
instance
instance
jupyter_notebook
read-knowledge0
publish-connection-parameter
publish-connection-parameter
jupyter-notebook-config
jupyter-notebook-config
erp5-kernel
erp5-kernel
...
@@ -91,13 +89,17 @@ environment =
...
@@ -91,13 +89,17 @@ environment =
JUPYTER_RUNTIME_DIR=${directory:jupyter_runtime_dir}
JUPYTER_RUNTIME_DIR=${directory:jupyter_runtime_dir}
LANG=C.UTF-8
LANG=C.UTF-8
[jupyter-password]
recipe = slapos.cookbook:generate.password
bytes = 10
[jupyter-notebook-config]
[jupyter-notebook-config]
<= dynamic-jinja2-template-base
<= dynamic-jinja2-template-base
template = {{ jupyter_config_location }}/{{ jupyter_config_filename }}
template = {{ jupyter_config_location }}/{{ jupyter_config_filename }}
rendered = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
rendered = ${directory:jupyter_config_dir}/jupyter_notebook_config.py
mode = 0744
mode = 0744
context =
context =
raw config_cfg ${buildout:directory}/knowledge0.cfg
key password jupyter-password:passwd
raw gcc_location {{ gcc_location }}
raw gcc_location {{ gcc_location }}
raw cythonplus_repository {{ cythonplus_repository }}
raw cythonplus_repository {{ cythonplus_repository }}
...
@@ -119,18 +121,6 @@ jupyter_custom_dir = ${:jupyter_config_dir}/custom
...
@@ -119,18 +121,6 @@ jupyter_custom_dir = ${:jupyter_config_dir}/custom
jupyter_nbextensions_dir = ${:jupyter_dir}/nbextensions
jupyter_nbextensions_dir = ${:jupyter_dir}/nbextensions
erp5_kernel_dir = ${:jupyter_kernel_dir}/ERP5
erp5_kernel_dir = ${:jupyter_kernel_dir}/ERP5
[jupyter_notebook]
# This part is called like this because knowledge0.write uses the part name for
# the section name in the config file.
recipe = slapos.cookbook:zero-knowledge.write
password =
filename = knowledge0.cfg
[read-knowledge0]
recipe = slapos.cookbook:zero-knowledge.read
filename = knowledge0.cfg
password =
[request-slave-frontend-base]
[request-slave-frontend-base]
recipe = slapos.cookbook:requestoptional
recipe = slapos.cookbook:requestoptional
server-url = ${slap-connection:server-url}
server-url = ${slap-connection:server-url}
...
@@ -178,7 +168,7 @@ monitor-base-url = ${monitor-frontend-promise:url}
...
@@ -178,7 +168,7 @@ monitor-base-url = ${monitor-frontend-promise:url}
# cors-domains = softinstXXXXX.host.vifib.net (or equivalent)
# cors-domains = softinstXXXXX.host.vifib.net (or equivalent)
# interface-url = https://softinstXXXXX.host.vifib.net/erp5/web_site_module/monitoring_rjs_unsafe
# interface-url = https://softinstXXXXX.host.vifib.net/erp5/web_site_module/monitoring_rjs_unsafe
instance-configuration =
instance-configuration =
raw jupyter-password ${
read-knowledge0:passwor
d}
raw jupyter-password ${
jupyter-password:passw
d}
[publish-connection-parameter]
[publish-connection-parameter]
recipe = slapos.cookbook:publish.serialised
recipe = slapos.cookbook:publish.serialised
...
@@ -190,7 +180,7 @@ jupyter-classic-url-additional = ${request-slave-frontend-additional:connection-
...
@@ -190,7 +180,7 @@ jupyter-classic-url-additional = ${request-slave-frontend-additional:connection-
url-additional = ${:jupyter-classic-url-additional}
url-additional = ${:jupyter-classic-url-additional}
jupyterlab-url-additional = ${request-slave-frontend-additional:connection-secure_access}/lab
jupyterlab-url-additional = ${request-slave-frontend-additional:connection-secure_access}/lab
{% endif %}
{% endif %}
password = ${
read-knowledge0:passwor
d}
password = ${
jupyter-password:passw
d}
[erp5-kernel]
[erp5-kernel]
recipe = slapos.cookbook:symbolic.link
recipe = slapos.cookbook:symbolic.link
...
...
software/jupyter/instance.cfg.in
View file @
8e3ac372
...
@@ -34,8 +34,6 @@ context =
...
@@ -34,8 +34,6 @@ context =
raw python_executable ${jupyter:python_executable}
raw python_executable ${jupyter:python_executable}
raw jupyter_config_location ${jupyter-notebook-config:location}
raw jupyter_config_location ${jupyter-notebook-config:location}
raw jupyter_config_filename ${jupyter-notebook-config:filename}
raw jupyter_config_filename ${jupyter-notebook-config:filename}
raw jupyter_set_password_location ${jupyter-set-password:location}
raw jupyter_set_password_filename ${jupyter-set-password:filename}
raw erp5_kernel_location ${erp5-kernel:location}
raw erp5_kernel_location ${erp5-kernel:location}
raw erp5_kernel_filename ${erp5-kernel:filename}
raw erp5_kernel_filename ${erp5-kernel:filename}
raw kernel_json_location ${kernel-json:location}
raw kernel_json_location ${kernel-json:location}
...
...
software/jupyter/jupyter_notebook_config.py.jinja
View file @
8e3ac372
...
@@ -3,39 +3,12 @@
...
@@ -3,39 +3,12 @@
things. It is run by IPython hence why it can use functions like get_config().
things. It is run by IPython hence why it can use functions like get_config().
'''
'''
import configparser
import configparser
import random
from notebook.auth import passwd
from notebook.auth import passwd
import os
import os
def random_password(length = 10):
result = ""
for i in range(0, length):
result = result + chr(random.randint(0, 25) + ord('a'))
return result
knowledge_0 = '{{ config_cfg }}'
if not os.path.exists(knowledge_0):
print("Your software does <b>not</b> embed 0-knowledge. \
This interface is useless in this case</body></html>")
exit(0)
c = get_config()
c = get_config()
parser = configparser.ConfigParser()
c.NotebookApp.password = passwd("{{ password }}")
parser.read(knowledge_0)
if not parser.has_section("jupyter_notebook"):
parser.add_section("jupyter_notebook")
if not parser.has_option("jupyter_notebook", "password") or \
parser.get("jupyter_notebook", "password") == "":
parser.set("jupyter_notebook", "password", random_password())
c.NotebookApp.password = passwd(parser.get("jupyter_notebook", "password"))
with open(knowledge_0, 'w') as file:
parser.write(file)
os.environ['PATH'] = "{{ gcc_location }}/bin" + os.pathsep + os.environ['PATH']
os.environ['PATH'] = "{{ gcc_location }}/bin" + os.pathsep + os.environ['PATH']
os.environ['PYTHONPATH'] = "{{ cythonplus_repository }}" + os.pathsep + os.environ['PYTHONPATH']
os.environ['PYTHONPATH'] = "{{ cythonplus_repository }}" + os.pathsep + os.environ['PYTHONPATH']
software/jupyter/jupyter_set_password.cgi.jinja
deleted
100644 → 0
View file @
ec1eba0b
#!{{ python_executable }}
import cgi
import cgitb
import ConfigParser
import os
import re
import subprocess
from IPython.lib import passwd
#cgitb.enable(display=0, logdir="/tmp/cgi.log")
cgitb.enable()
form = cgi.FieldStorage()
config_file = "{{ config_cfg }}"
if not os.path.exists(config_file):
print "Your software does
<b>
not
</b>
embed 0-knowledge. \
This interface is useless in this case
</body></html>
"
exit(0)
parser = ConfigParser.ConfigParser()
parser.read(config_file)
if not parser.has_section("jupyter_notebook"):
parser.add_section("jupyter_notebook")
if not parser.has_option("jupyter_notebook", "password"):
parser.set("jupyter_notebook", "password", "")
if "password" in form:
parser.set("jupyter_notebook", "password", passwd(form["password"].value))
# subprocess.call('{{ httpd_graceful }}')
# TODO: we should restart jupyter
with open(config_file, 'w') as file:
parser.write(file)
# TODO cleanup
print "
<html><head>
"
print "
<link
rel=
\"stylesheet\"
href=
\"static/pure-min.css\"
>
"
print "
<link
rel=
\"stylesheet\"
href=
\"static/style.css\"
>
"
print "
</head><body>
"
print "
<h1>
Jupyter Notebook Password :
</h1>
"
print "
<form
action=
\"/index.cgi\"
method=
\"post\"
class=
\"pure-form-aligned\"
>
"
print "
<input
type=
\"hidden\"
name=
\"posting-script\"
value=
\"{{
pwd
}}/{{
this_file
}}\"
>
"
print """
<div
class=
"pure-control-group"
>
<label
for=
"password"
>
Password*:
</label>
<input
placeholder=
"Set your password"
type=
"password"
name=
"password"
id=
"password"
></br>
</div><div
class=
"pure-control-group"
>
<label
for=
"password"
>
Verify Password*:
</label>
<input
placeholder=
"Verify password"
type=
"password"
name=
"password_2"
id=
"password_2"
></br>
</div><p
id=
"validate-status"
style=
"color:red"
></p>
<div
class=
"pure-controls"
>
<button
id=
"register-button"
type=
"submit"
class=
"pure-button pure-button-primary"
disabled
>
Access
</button></div>
</form>
<script
type=
"text/javascript"
src=
"static/jquery-1.10.2.min.js"
></script>
<script
type=
"text/javascript"
src=
"static/monitor-register.js"
></script>
</body></html>
"""
software/jupyter/software.cfg
View file @
8e3ac372
...
@@ -31,9 +31,6 @@ mode = 0644
...
@@ -31,9 +31,6 @@ mode = 0644
[jupyter-notebook-config]
[jupyter-notebook-config]
<= download-file-base
<= download-file-base
[jupyter-set-password]
<= download-file-base
[erp5-kernel]
[erp5-kernel]
<= download-file-base
<= download-file-base
...
...
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