diff --git a/.gitignore b/.gitignore index 931261a..e26c2c4 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -*.key \ No newline at end of file +*.key +__pycache__/ \ No newline at end of file diff --git a/srv/avalon.py b/srv/avalon.py new file mode 100644 index 0000000..b79ab81 --- /dev/null +++ b/srv/avalon.py @@ -0,0 +1,7 @@ +from avdefs import AccountType + +class AvalonConnection: + + def __init__(self): + self.acuser: str = "anon" + self.actype: AccountType = AccountType.ANON \ No newline at end of file diff --git a/srv/avdefs.py b/srv/avdefs.py new file mode 100644 index 0000000..d551779 --- /dev/null +++ b/srv/avdefs.py @@ -0,0 +1,7 @@ +from enum import Enum, auto + +class AccountType(Enum): + + ANON = auto() + LDAP = auto() + AKEY = auto() \ No newline at end of file diff --git a/ldaputil.py b/util/ldaputil.py similarity index 88% rename from ldaputil.py rename to util/ldaputil.py index a3bd1ea..ba27f51 100644 --- a/ldaputil.py +++ b/util/ldaputil.py @@ -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 \ No newline at end of file + return False + +if __name__ == "__main__": + print(authenticate(input("Avalon Username: "), getpass("Avalon Password: "))) \ No newline at end of file diff --git a/web/app.py b/web/app.py new file mode 100644 index 0000000..7232d4a --- /dev/null +++ b/web/app.py @@ -0,0 +1,3 @@ +from flask import Flask + +app = Flask(__name__) \ No newline at end of file