From 7ba71b5eefcf15bb21aea17bd7f4d9cba4fa9680 Mon Sep 17 00:00:00 2001 From: dece Date: Sat, 27 Nov 2021 16:04:04 +0100 Subject: [PATCH] smolcgi: add require_cool_client --- check-email | 2 ++ smolcgi.py | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/check-email b/check-email index 6503bb9..222e598 100755 --- a/check-email +++ b/check-email @@ -7,6 +7,8 @@ import subprocess import smolcgi +smolcgi.require_cool_client("This script is not publicly available, sorry!") + if not smolcgi.query_string_dec: smolcgi.require_input("Provide an email address to check.") diff --git a/smolcgi.py b/smolcgi.py index cc1a9ae..88e0634 100644 --- a/smolcgi.py +++ b/smolcgi.py @@ -142,6 +142,14 @@ def cert_not_authorised(reason=""): exit_with_header(61, reason) +def require_cool_client(reason=""): + require_client_cert() + with open(get_storage_path() / "cool_hashes", "rt") as f: + cool_hashes = f.read().rstrip().split("\n") + if tls_client_hash not in cool_hashes: + cert_not_authorised(reason) + + def cert_not_valid(reason=""): exit_with_header(62, reason)