stubbing out cgi-example

This commit is contained in:
James Tomasino 2022-02-20 20:50:55 +00:00
parent 82f207b6d7
commit 661858a616
3 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,14 @@
BEGIN TRANSACTION;
CREATE TABLE IF NOT EXISTS "certs" (
"hash" TEXT NOT NULL UNIQUE,
"user_id" INTEGER,
PRIMARY KEY("hash"),
FOREIGN KEY("user_id") REFERENCES "users"("id")
);
CREATE TABLE IF NOT EXISTS "users" (
"id" INTEGER NOT NULL UNIQUE,
"name" TEXT,
"add_key_code" TEXT,
PRIMARY KEY("id" AUTOINCREMENT)
);
COMMIT;

19
cgi-example/helpers.py Normal file
View File

@ -0,0 +1,19 @@
#!/bin/python
import os
def get_client_cert():
TLS_CLIENT_HASH = os.getenv('TLS_CLIENT_HASH')
if(TLS_CLIENT_HASH is None):
show_header_cert_required()
else:
show_header_ok()
return TLS_CLIENT_HASH
def show_header_ok():
print("20 text/gemini; charset=utf-8", end = "\r\n")
def show_header_cert_required():
print("60 text/gemini; charset=utf-8", end = "\r\n")
quit()
#vim:fenc=utf-8:ts=4:sw=4:sta:noet:sts=4:fdm=marker:ai

8
cgi-example/index.gmi Executable file
View File

@ -0,0 +1,8 @@
#!/bin/python
from helpers import get_client_cert
TLS_CLIENT_HASH = get_client_cert()
print("TLS_CLIENT_HASH:")
print(TLS_CLIENT_HASH)
#vim:fenc=utf-8:ts=4:sw=4:sta:noet:sts=4:fdm=marker:ai