Merge ~andersson123/autopkgtest-cloud:login-button into autopkgtest-cloud:master

Proposed by Tim Andersson
Status: Merged
Merged at revision: 8acb37193c075fa21042f0434b515ae6ba3a26d0
Proposed branch: ~andersson123/autopkgtest-cloud:login-button
Merge into: autopkgtest-cloud:master
Diff against target: 65 lines (+16/-2)
3 files modified
charms/focal/autopkgtest-web/webcontrol/browse.cgi (+11/-2)
charms/focal/autopkgtest-web/webcontrol/request/app.py (+2/-0)
charms/focal/autopkgtest-web/webcontrol/templates/browse-layout.html (+3/-0)
Reviewer Review Type Date Requested Status
Skia Approve
Review via email: mp+463211@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Tim Andersson (andersson123) wrote :

going to test this in staging now.

Revision history for this message
Tim Andersson (andersson123) wrote :

tested and functioning as intended.

Revision history for this message
Skia (hyask) :
review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) wrote :

amended and ready for re-review, thanks for the helpful tips!

Revision history for this message
Tim Andersson (andersson123) wrote :

hm, there's some unnecessary changes in this mp

Revision history for this message
Skia (hyask) :
review: Needs Fixing
Revision history for this message
Tim Andersson (andersson123) :
Revision history for this message
Skia (hyask) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/charms/focal/autopkgtest-web/webcontrol/browse.cgi b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
2index 5e5217b..93758e4 100755
3--- a/charms/focal/autopkgtest-web/webcontrol/browse.cgi
4+++ b/charms/focal/autopkgtest-web/webcontrol/browse.cgi
5@@ -13,15 +13,23 @@ from wsgiref.handlers import CGIHandler
6 import flask
7 from helpers.admin import select_abnormally_long_jobs
8 from helpers.exceptions import RunningJSONNotFound
9-from helpers.utils import get_all_releases, get_supported_releases
10+from helpers.utils import get_all_releases, get_supported_releases, setup_key
11 from werkzeug.middleware.proxy_fix import ProxyFix
12
13+# Initialize app
14+PATH = os.path.join(
15+ os.path.sep, os.getenv("XDG_RUNTIME_DIR", "/run"), "autopkgtest_webcontrol"
16+)
17+os.makedirs(PATH, exist_ok=True)
18 app = flask.Flask("browse")
19-
20 # we don't want a long cache, as we only serve files that are regularly updated
21 app.config["SEND_FILE_MAX_AGE_DEFAULT"] = 60
22
23 app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=1)
24+
25+secret_path = os.path.join(PATH, "secret_key")
26+setup_key(app, secret_path)
27+
28 db_con = None
29 swift_container_url = None
30
31@@ -245,6 +253,7 @@ def success_count_for_release_and_arch(db, release, arch, src_versions):
32
33 @app.route("/")
34 def index_root():
35+ flask.session.permanent = True
36 letters = list("abcdefghijklmnopqrstuvwxyz")
37 indexes = letters + ["lib" + l for l in letters]
38 indexes.sort()
39diff --git a/charms/focal/autopkgtest-web/webcontrol/request/app.py b/charms/focal/autopkgtest-web/webcontrol/request/app.py
40index a4a3367..422a40a 100644
41--- a/charms/focal/autopkgtest-web/webcontrol/request/app.py
42+++ b/charms/focal/autopkgtest-web/webcontrol/request/app.py
43@@ -273,6 +273,8 @@ def index_root():
44 elif nick:
45 params["requester"] = nick
46 s = Submit()
47+ if list(params.keys()) == ["/login", "requester"]:
48+ return redirect("/")
49 try:
50 s.validate_args(params)
51 s.validate_distro_request(**params)
52diff --git a/charms/focal/autopkgtest-web/webcontrol/templates/browse-layout.html b/charms/focal/autopkgtest-web/webcontrol/templates/browse-layout.html
53index c91457d..e4cfce6 100644
54--- a/charms/focal/autopkgtest-web/webcontrol/templates/browse-layout.html
55+++ b/charms/focal/autopkgtest-web/webcontrol/templates/browse-layout.html
56@@ -34,6 +34,9 @@
57 <li><a href="https://discourse.ubuntu.com/t/autopkgtest-service/34490">Service Status</a></li>
58 <li><a href="https://autopkgtest-cloud.readthedocs.io/">Docs for admins</a></li>
59 <li><a href="{{base_url}}admin">Admin</a></li>
60+ {% if not session.get("nickname") %}
61+ <li><a href="{{base_url}}request.cgi?/login">Login</a></li>
62+ {% endif %}
63 </ul>
64 </div><!--/.nav-collapse -->
65 </div>

Subscribers

People subscribed via source and target branches