Compare commits

..
2 Commits
Author SHA1 Message Date
morgana d7e4f701b4 Implement base Avalon LDAP authentication utility 2026-01-14 14:52:17 -06:00
morgana 460aaef74d Initial commit 2026-01-14 13:58:01 -06:00
7 changed files with 4 additions and 87 deletions
+1 -2
View File
@@ -1,2 +1 @@
*.key *.key
__pycache__/
+3 -6
View File
@@ -25,7 +25,7 @@ SEARCH_DN = "cn=Search,dc=icolotl,dc=com"
with open("search.key", encoding="utf-8") as file: with open("search.key", encoding="utf-8") as file:
SEARCH_KEY = file.read().strip() SEARCH_KEY = file.read().strip()
def authenticate(username: str, password: str): def authenticate(username, password):
"""Attempt to authenticate against the Avalon LDAP Database.""" """Attempt to authenticate against the Avalon LDAP Database."""
server = Server("127.0.0.1") server = Server("127.0.0.1")
try: try:
@@ -33,11 +33,8 @@ def authenticate(username: str, password: str):
conn.search("ou=People,dc=icolotl,dc=com", f"(&(objectclass=person)(uid={escape_filter_chars(username)}))") conn.search("ou=People,dc=icolotl,dc=com", f"(&(objectclass=person)(uid={escape_filter_chars(username)}))")
if len(conn.entries) != 1: if len(conn.entries) != 1:
return False return False
USER_DN: str = conn.entries[0].entry_dn USER_DN = conn.entries[0].entry_dn
with Connection(server, user=USER_DN, password=password, raise_exceptions=True): with Connection(server, user=USER_DN, password=password, raise_exceptions=True):
return True return True
except (LDAPBindError, LDAPPasswordIsMandatoryError, LDAPInvalidCredentialsResult): except (LDAPBindError, LDAPPasswordIsMandatoryError, LDAPInvalidCredentialsResult):
return False return False
if __name__ == "__main__":
print(authenticate(input("Avalon Username: "), getpass("Avalon Password: ")))
-24
View File
@@ -1,24 +0,0 @@
#!/usr/bin/env python3
# avalon-bbs avalon.py
# Copyright (C) 2026 The Avalon Team <avalon@icolotl.com>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from avdefs import AccountType
class AvalonConnection:
def __init__(self):
self.acuser: str = "anon"
self.actype: AccountType = AccountType.ANON
-24
View File
@@ -1,24 +0,0 @@
#!/usr/bin/env python3
# avalon-bbs avdefs.py
# Copyright (C) 2026 The Avalon Team <avalon@icolotl.com>
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option) any
# later version.
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
# You should have received a copy of the GNU Affero General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum, auto
class AccountType(Enum):
ANON = auto()
LDAP = auto()
AKEY = auto()
-11
View File
@@ -1,11 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Avalon BBS</title>
<link rel="stylesheet" href="style.css">
<script src="script.js" defer></script>
</head>
<body>
<h1>Avalon BBS</h1>
</body>
</html>
-16
View File
@@ -1,16 +0,0 @@
/*
* avalon-bbs script.js
* Copyright (C) 2026 The Avalon Team <avalon@icolotl.com>
*
* This program is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any
* later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
* PARTICULAR PURPOSE. See the GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-4
View File
@@ -1,4 +0,0 @@
html {
background-color: #222;
color: #f0a;
}