Implement AI workspace and mitigation workflow
This commit is contained in:
@@ -1,16 +1,18 @@
|
||||
|
||||
# Create a debug log to confirm script execution
|
||||
|
||||
import sys
|
||||
import django
|
||||
import os
|
||||
import sys
|
||||
|
||||
import django
|
||||
|
||||
LOG_PATH = "auth_debug.log"
|
||||
|
||||
|
||||
def log(data):
|
||||
with open(LOG_PATH, "a") as f:
|
||||
f.write(f"{data}\n")
|
||||
|
||||
|
||||
# Set up Django environment
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "app.settings") # Adjust if needed
|
||||
django.setup()
|
||||
@@ -18,11 +20,13 @@ django.setup()
|
||||
from django.contrib.auth import authenticate
|
||||
from django.contrib.auth.models import User
|
||||
|
||||
|
||||
def check_credentials(username, password):
|
||||
"""Authenticate user via Django"""
|
||||
user = authenticate(username=username, password=password)
|
||||
return user is not None and user.is_active
|
||||
|
||||
|
||||
def main():
|
||||
"""Process authentication requests from Prosody"""
|
||||
while True:
|
||||
@@ -42,7 +46,9 @@ def main():
|
||||
continue
|
||||
|
||||
command, username, domain = parts[:3]
|
||||
password = ":".join(parts[3:]) if len(parts) > 3 else None # Reconstruct password
|
||||
password = (
|
||||
":".join(parts[3:]) if len(parts) > 3 else None
|
||||
) # Reconstruct password
|
||||
|
||||
if command == "auth":
|
||||
if password and check_credentials(username, password):
|
||||
@@ -71,5 +77,6 @@ def main():
|
||||
log(f"Error: {str(e)}\n")
|
||||
print("0", flush=True) # Return failure for any error
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user