BBS Server Structure
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -1 +1,2 @@
|
||||
*.key
|
||||
*.key
|
||||
__pycache__/
|
||||
7
srv/avalon.py
Normal file
7
srv/avalon.py
Normal 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
7
srv/avdefs.py
Normal file
@@ -0,0 +1,7 @@
|
||||
from enum import Enum, auto
|
||||
|
||||
class AccountType(Enum):
|
||||
|
||||
ANON = auto()
|
||||
LDAP = auto()
|
||||
AKEY = auto()
|
||||
@@ -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
3
web/app.py
Normal file
@@ -0,0 +1,3 @@
|
||||
from flask import Flask
|
||||
|
||||
app = Flask(__name__)
|
||||
Reference in New Issue
Block a user