BBS Server Structure

This commit is contained in:
2026-02-09 14:36:55 -06:00
parent 50a169cd89
commit 7732952e9c
5 changed files with 25 additions and 4 deletions

3
.gitignore vendored
View File

@@ -1 +1,2 @@
*.key
*.key
__pycache__/

7
srv/avalon.py Normal file
View File

@@ -0,0 +1,7 @@
from avdefs import AccountType
class AvalonConnection:
def __init__(self):
self.acuser: str = "anon"
self.actype: AccountType = AccountType.ANON

7
srv/avdefs.py Normal file
View File

@@ -0,0 +1,7 @@
from enum import Enum, auto
class AccountType(Enum):
ANON = auto()
LDAP = auto()
AKEY = auto()

View File

@@ -25,7 +25,7 @@ SEARCH_DN = "cn=Search,dc=icolotl,dc=com"
with open("search.key", encoding="utf-8") as file:
SEARCH_KEY = file.read().strip()
def authenticate(username, password):
def authenticate(username: str, password: str):
"""Attempt to authenticate against the Avalon LDAP Database."""
server = Server("127.0.0.1")
try:
@@ -33,8 +33,11 @@ def authenticate(username, password):
conn.search("ou=People,dc=icolotl,dc=com", f"(&(objectclass=person)(uid={escape_filter_chars(username)}))")
if len(conn.entries) != 1:
return False
USER_DN = conn.entries[0].entry_dn
USER_DN: str = conn.entries[0].entry_dn
with Connection(server, user=USER_DN, password=password, raise_exceptions=True):
return True
except (LDAPBindError, LDAPPasswordIsMandatoryError, LDAPInvalidCredentialsResult):
return False
return False
if __name__ == "__main__":
print(authenticate(input("Avalon Username: "), getpass("Avalon Password: ")))

3
web/app.py Normal file
View File

@@ -0,0 +1,3 @@
from flask import Flask
app = Flask(__name__)