This repository has been archived on 2024-05-17. You can view files and clone it, but cannot push or open issues or pull requests.
gemini-auth/public/cgi/index.gmi

28 lines
712 B
Plaintext
Executable File

#!/usr/bin/python3
# This is just a little example of home page, change it as you see fit.
import os
import sys
os.chdir('..')
sys.path.append('lib')
hash = os.environ.get('TLS_CLIENT_HASH')
if (not hash):
print('60 Authentication is required\r\n')
exit()
cert_name = os.environ.get('REMOTE_USER')
print('20 text/gemini\r\n')
from auth import auth
auth = auth('data/data.db')
auth.pass_key(hash, cert_name)
print('Your hash:', auth.hash)
print('Your common name:', cert_name)
if (auth.username):
print('Your username:', auth.username)
print('=> account/index.gmi manage your account')
else:
print('=> account/register.gmi register')
print('=> account/link.gmi link existing account')