diff --git a/daemon.py b/daemon.py index 182f3c194..dd3b62cbc 100644 --- a/daemon.py +++ b/daemon.py @@ -1059,6 +1059,15 @@ class PubServer(BaseHTTPRequestHandler): 'This is nothing less ' + 'than an utter triumph', None) + def _401(self, post_msg: str) -> None: + if self.server.translate: + ok_str = self.server.translate[post_msg] + self._http_return_code(401, self.server.translate['Unauthorized'], + ok_str, None) + else: + self._http_return_code(401, 'Unauthorized', + post_msg, None) + def _201(self, etag: str) -> None: if self.server.translate: done_str = self.server.translate['It is done'] @@ -2050,12 +2059,12 @@ class PubServer(BaseHTTPRequestHandler): 'epicyon=; SameSite=Strict', calling_domain) - def _show_login_screen(self, calling_domain: str, cookie: str, + def _post_login_screen(self, calling_domain: str, cookie: str, base_dir: str, http_prefix: str, domain: str, domain_full: str, port: int, onion_domain: str, i2p_domain: str, ua_str: str) -> None: - """Shows the login screen + """POST to login screen, containing credentials """ # ensure that there is a minimum delay between failed login # attempts, to mitigate brute force @@ -2068,8 +2077,7 @@ class PubServer(BaseHTTPRequestHandler): length = int(self.headers['Content-length']) if length > 512: print('Login failed - credentials too long') - self.send_response(401) - self.end_headers() + self._401('Credentials are too long') self.server.postreq_busy = False return @@ -2096,7 +2104,7 @@ class PubServer(BaseHTTPRequestHandler): html_get_login_credentials(login_params, self.server.last_login_time, domain) - if login_nickname: + if login_nickname and login_password: if is_system_account(login_nickname): print('Invalid username login: ' + login_nickname + ' (system account)') @@ -2248,6 +2256,10 @@ class PubServer(BaseHTTPRequestHandler): cookie_str, calling_domain) self.server.postreq_busy = False return + else: + print('WARN: No login credentials presented to /login') + self._401('No login credentials were posted') + self.server.postreq_busy = False self._200() self.server.postreq_busy = False @@ -20044,9 +20056,9 @@ class PubServer(BaseHTTPRequestHandler): '_POST', 'start', self.server.debug) - # login screen + # POST to login screen, containing credentials if self.path.startswith('/login'): - self._show_login_screen(calling_domain, cookie, + self._post_login_screen(calling_domain, cookie, self.server.base_dir, self.server.http_prefix, self.server.domain, diff --git a/translations/ar.json b/translations/ar.json index 23dd72d4f..6ff8d37be 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -587,5 +587,8 @@ "Last 2 weeks": "آخر أسبوعين", "Last month": "الشهر الماضي", "Last 6 months": "آخر 6 أشهر", - "Last year": "العام الماضي" + "Last year": "العام الماضي", + "Unauthorized": "غير مصرح", + "No login credentials were posted": "لم يتم نشر بيانات اعتماد تسجيل الدخول", + "Credentials are too long": "أوراق الاعتماد طويلة جدًا" } diff --git a/translations/bn.json b/translations/bn.json index 54864b4ae..ab0391319 100644 --- a/translations/bn.json +++ b/translations/bn.json @@ -587,5 +587,8 @@ "Last 2 weeks": "গত ২ সপ্তাহ", "Last month": "গত মাসে", "Last 6 months": "গত ৬ মাস", - "Last year": "গত বছর" + "Last year": "গত বছর", + "Unauthorized": "অননুমোদিত", + "No login credentials were posted": "কোনো লগইন শংসাপত্র পোস্ট করা হয়নি", + "Credentials are too long": "শংসাপত্রগুলি খুব দীর্ঘ৷" } diff --git a/translations/ca.json b/translations/ca.json index b7d4cff5e..4026c8d68 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Últimes 2 setmanes", "Last month": "El mes passat", "Last 6 months": "Últims 6 mesos", - "Last year": "L'any passat" + "Last year": "L'any passat", + "Unauthorized": "No autoritzat", + "No login credentials were posted": "No s'ha publicat cap credencial d'inici de sessió", + "Credentials are too long": "Les credencials són massa llargues" } diff --git a/translations/cy.json b/translations/cy.json index fa7b24a18..5a5c76311 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -587,5 +587,8 @@ "Last 2 weeks": "2 wythnos diwethaf", "Last month": "Mis diwethaf", "Last 6 months": "6 mis diwethaf", - "Last year": "Blwyddyn diwethaf" + "Last year": "Blwyddyn diwethaf", + "Unauthorized": "Anawdurdodedig", + "No login credentials were posted": "Ni bostiwyd unrhyw fanylion mewngofnodi", + "Credentials are too long": "Mae manylion yn rhy hir" } diff --git a/translations/de.json b/translations/de.json index 8fe4df906..282a36023 100644 --- a/translations/de.json +++ b/translations/de.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Letzte 2 Wochen", "Last month": "Im vergangenen Monat", "Last 6 months": "Letzte 6 Monate", - "Last year": "Vergangenes Jahr" + "Last year": "Vergangenes Jahr", + "Unauthorized": "Unbefugt", + "No login credentials were posted": "Es wurden keine Zugangsdaten gepostet", + "Credentials are too long": "Anmeldeinformationen sind zu lang" } diff --git a/translations/el.json b/translations/el.json index 494933a97..0778d0b58 100644 --- a/translations/el.json +++ b/translations/el.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Τελευταίες 2 εβδομάδες", "Last month": "Τον προηγούμενο μήνα", "Last 6 months": "Τελευταίοι 6 μήνες", - "Last year": "Πέρυσι" + "Last year": "Πέρυσι", + "Unauthorized": "Ανεξουσιοδότητος", + "No login credentials were posted": "Δεν δημοσιεύτηκαν διαπιστευτήρια σύνδεσης", + "Credentials are too long": "Τα διαπιστευτήρια είναι πολύ μεγάλα" } diff --git a/translations/en.json b/translations/en.json index 286e83ae6..7786801e4 100644 --- a/translations/en.json +++ b/translations/en.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Last 2 weeks", "Last month": "Last month", "Last 6 months": "Last 6 months", - "Last year": "Last year" + "Last year": "Last year", + "Unauthorized": "Unauthorized", + "No login credentials were posted": "No login credentials were posted", + "Credentials are too long": "Credentials are too long" } diff --git a/translations/es.json b/translations/es.json index 7faf7bf54..ea16525b9 100644 --- a/translations/es.json +++ b/translations/es.json @@ -587,5 +587,8 @@ "Last 2 weeks": "últimas 2 semanas", "Last month": "El mes pasado", "Last 6 months": "últimos 6 meses", - "Last year": "El año pasado" + "Last year": "El año pasado", + "Unauthorized": "No autorizado", + "No login credentials were posted": "No se publicaron credenciales de inicio de sesión", + "Credentials are too long": "Las credenciales son demasiado largas" } diff --git a/translations/fr.json b/translations/fr.json index 3987da5df..6b0599a41 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -587,5 +587,8 @@ "Last 2 weeks": "2 dernières semaines", "Last month": "Le mois dernier", "Last 6 months": "6 derniers mois", - "Last year": "L'année dernière" + "Last year": "L'année dernière", + "Unauthorized": "Non autorisé", + "No login credentials were posted": "Aucun identifiant de connexion n'a été posté", + "Credentials are too long": "Les identifiants sont trop longs" } diff --git a/translations/ga.json b/translations/ga.json index 63e515d2b..3d2ad5f0a 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -587,5 +587,8 @@ "Last 2 weeks": "2 sheachtain anuas", "Last month": "An mhí seo caite", "Last 6 months": "6 mhí anuas", - "Last year": "Anuraidh" + "Last year": "Anuraidh", + "Unauthorized": "Neamhúdaraithe", + "No login credentials were posted": "Níor postáladh aon dintiúir logáil isteach", + "Credentials are too long": "Tá dintiúir ró-fhada" } diff --git a/translations/hi.json b/translations/hi.json index 846975dd5..d4e2bbd42 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -587,5 +587,8 @@ "Last 2 weeks": "पिछले 2 सप्ताह", "Last month": "पिछले महीने", "Last 6 months": "पिछले 6 महीने", - "Last year": "पिछले साल" + "Last year": "पिछले साल", + "Unauthorized": "अनधिकृत", + "No login credentials were posted": "कोई लॉगिन क्रेडेंशियल पोस्ट नहीं किया गया था", + "Credentials are too long": "क्रेडेंशियल बहुत लंबे हैं" } diff --git a/translations/it.json b/translations/it.json index c4589b9e2..122c7847a 100644 --- a/translations/it.json +++ b/translations/it.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Ultime 2 settimane", "Last month": "Lo scorso mese", "Last 6 months": "Ultimi 6 mesi", - "Last year": "L'anno scorso" + "Last year": "L'anno scorso", + "Unauthorized": "Non autorizzato", + "No login credentials were posted": "Non sono state pubblicate credenziali di accesso", + "Credentials are too long": "Le credenziali sono troppo lunghe" } diff --git a/translations/ja.json b/translations/ja.json index 8ad785b4c..ee327ae96 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -587,5 +587,8 @@ "Last 2 weeks": "過去 2 週間", "Last month": "先月", "Last 6 months": "過去 6 か月", - "Last year": "去年" + "Last year": "去年", + "Unauthorized": "無許可", + "No login credentials were posted": "ログイン認証情報が投稿されていません", + "Credentials are too long": "資格情報が長すぎます" } diff --git a/translations/ko.json b/translations/ko.json index a8650073a..868b6bb4e 100644 --- a/translations/ko.json +++ b/translations/ko.json @@ -587,5 +587,8 @@ "Last 2 weeks": "지난 2주", "Last month": "지난 달", "Last 6 months": "지난 6개월", - "Last year": "작년" + "Last year": "작년", + "Unauthorized": "무단", + "No login credentials were posted": "게시된 로그인 자격 증명이 없습니다.", + "Credentials are too long": "자격 증명이 너무 깁니다." } diff --git a/translations/ku.json b/translations/ku.json index 746954a94..54df7dbd3 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -587,5 +587,8 @@ "Last 2 weeks": "2 hefteyên dawî", "Last month": "meha borî", "Last 6 months": "6 mehên dawî", - "Last year": "Sala borî" + "Last year": "Sala borî", + "Unauthorized": "Bêmaf", + "No login credentials were posted": "Tu pêbaweriyên têketinê nehatin şandin", + "Credentials are too long": "Bawernameyên pir dirêj in" } diff --git a/translations/nl.json b/translations/nl.json index 3d55f27cb..c454edc4d 100644 --- a/translations/nl.json +++ b/translations/nl.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Afgelopen 2 weken", "Last month": "Vorige maand", "Last 6 months": "Afgelopen 6 maanden", - "Last year": "Afgelopen jaar" + "Last year": "Afgelopen jaar", + "Unauthorized": "Ongeautoriseerd", + "No login credentials were posted": "Er zijn geen inloggegevens gepost", + "Credentials are too long": "Inloggegevens zijn te lang" } diff --git a/translations/oc.json b/translations/oc.json index acdc5e8a2..29ec2857c 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -583,5 +583,8 @@ "Last 2 weeks": "Last 2 weeks", "Last month": "Last month", "Last 6 months": "Last 6 months", - "Last year": "Last year" + "Last year": "Last year", + "Unauthorized": "Unauthorized", + "No login credentials were posted": "No login credentials were posted", + "Credentials are too long": "Credentials are too long" } diff --git a/translations/pl.json b/translations/pl.json index 46494b7bf..9af7f9dcc 100644 --- a/translations/pl.json +++ b/translations/pl.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Ostatnie 2 tygodnie", "Last month": "W zeszłym miesiącu", "Last 6 months": "Ostatnie 6 miesięcy", - "Last year": "Ostatni rok" + "Last year": "Ostatni rok", + "Unauthorized": "Nieautoryzowany", + "No login credentials were posted": "Nie opublikowano danych logowania", + "Credentials are too long": "Poświadczenia są za długie" } diff --git a/translations/pt.json b/translations/pt.json index f20e98655..2d7d88d55 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Últimas 2 semanas", "Last month": "Mês passado", "Last 6 months": "Últimos 6 meses", - "Last year": "Ano passado" + "Last year": "Ano passado", + "Unauthorized": "Não autorizado", + "No login credentials were posted": "Nenhuma credencial de login foi postada", + "Credentials are too long": "As credenciais são muito longas" } diff --git a/translations/ru.json b/translations/ru.json index 8ccd46371..4188c23af 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Последние 2 недели", "Last month": "Прошлый месяц", "Last 6 months": "Последние 6 месяцев", - "Last year": "Прошедший год" + "Last year": "Прошедший год", + "Unauthorized": "Неавторизованный", + "No login credentials were posted": "Учетные данные для входа не были отправлены", + "Credentials are too long": "Учетные данные слишком длинные" } diff --git a/translations/sw.json b/translations/sw.json index eba0e4f97..30dc696ac 100644 --- a/translations/sw.json +++ b/translations/sw.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Wiki 2 zilizopita", "Last month": "Mwezi uliopita", "Last 6 months": "Miezi 6 iliyopita", - "Last year": "Mwaka jana" + "Last year": "Mwaka jana", + "Unauthorized": "Haijaidhinishwa", + "No login credentials were posted": "Hakuna kitambulisho cha kuingia kilichochapishwa", + "Credentials are too long": "Kitambulisho ni kirefu sana" } diff --git a/translations/tr.json b/translations/tr.json index 1c1f713d5..efcc36f80 100644 --- a/translations/tr.json +++ b/translations/tr.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Son 2 hafta", "Last month": "Geçen ay", "Last 6 months": "Son 6 ay", - "Last year": "Geçen yıl" + "Last year": "Geçen yıl", + "Unauthorized": "Yetkisiz", + "No login credentials were posted": "Giriş bilgileri gönderilmedi", + "Credentials are too long": "Kimlik bilgileri çok uzun" } diff --git a/translations/uk.json b/translations/uk.json index 8bad61475..923d202d4 100644 --- a/translations/uk.json +++ b/translations/uk.json @@ -587,5 +587,8 @@ "Last 2 weeks": "Останні 2 тижні", "Last month": "Минулого місяця", "Last 6 months": "Останні 6 місяців", - "Last year": "Минулого року" + "Last year": "Минулого року", + "Unauthorized": "Несанкціонований", + "No login credentials were posted": "Облікові дані для входу не опубліковано", + "Credentials are too long": "Облікові дані задовгі" } diff --git a/translations/yi.json b/translations/yi.json index 9b8c60c6a..a52868036 100644 --- a/translations/yi.json +++ b/translations/yi.json @@ -587,5 +587,8 @@ "Last 2 weeks": "לעצטע 2 וואָכן", "Last month": "לעצטע מאנאט", "Last 6 months": "לעצטע 6 חדשים", - "Last year": "לעצטע יאר" + "Last year": "לעצטע יאר", + "Unauthorized": "אַנאָטערייזד", + "No login credentials were posted": "קיין לאָגין קראַדענטשאַלז זענען אַרייַנגעשיקט", + "Credentials are too long": "קראַדענטשאַלז זענען צו לאַנג" } diff --git a/translations/zh.json b/translations/zh.json index 06cd25aee..546709ed7 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -587,5 +587,8 @@ "Last 2 weeks": "过去 2 周", "Last month": "上个月", "Last 6 months": "过去 6 个月", - "Last year": "去年" + "Last year": "去年", + "Unauthorized": "未经授权", + "No login credentials were posted": "未发布登录凭据", + "Credentials are too long": "凭据太长" } diff --git a/webapp_login.py b/webapp_login.py index 101a01b47..4dd22a6a4 100644 --- a/webapp_login.py +++ b/webapp_login.py @@ -30,7 +30,7 @@ def html_get_login_credentials(loginParams: str, return None, None, None # minimum time between login attempts curr_time = int(time.time()) - if curr_time < last_login_time+10: + if curr_time < last_login_time + 10: return None, None, None if '&' not in loginParams: return None, None, None