Compare commits
2 Commits
50a169cd89
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 78bee32535 | |||
| 7732952e9c |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1 +1,2 @@
|
|||||||
*.key
|
*.key
|
||||||
|
__pycache__/
|
||||||
24
srv/avalon.py
Normal file
24
srv/avalon.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/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
srv/avdefs.py
Normal file
24
srv/avdefs.py
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
#!/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()
|
||||||
@@ -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, password):
|
def authenticate(username: str, password: str):
|
||||||
"""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,8 +33,11 @@ def authenticate(username, password):
|
|||||||
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 = conn.entries[0].entry_dn
|
USER_DN: str = 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: ")))
|
||||||
11
web/index.html
Normal file
11
web/index.html
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<!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
web/script.js
Normal file
16
web/script.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
/*
|
||||||
|
* 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
web/style.css
Normal file
4
web/style.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
html {
|
||||||
|
background-color: #222;
|
||||||
|
color: #f0a;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user