commit 48acef043671c4ef7e93635f6267b1996c9326d0 Author: steev Date: Mon Dec 4 13:38:21 2023 +0100 initial commit - added auth server diff --git a/Auth Server/.env b/Auth Server/.env new file mode 100644 index 0000000..ffe3ac9 --- /dev/null +++ b/Auth Server/.env @@ -0,0 +1,3 @@ +HOST="127.0.0.1" +PORT=54321 +ENV="DEV" \ No newline at end of file diff --git a/Auth Server/index.py b/Auth Server/index.py new file mode 100644 index 0000000..6985d17 --- /dev/null +++ b/Auth Server/index.py @@ -0,0 +1,66 @@ +import socket +import threading +import os +import json +from dotenv import load_dotenv + +load_dotenv() + +# retrieves host data from environment +HOST = os.getenv("HOST") +PORT = os.getenv("PORT") + +# TODO: setup tcp service for authorization +def handle_connection(socket:socket, address): + # states that a connection has been established + print(f"Connected with {address}") + + # Communication with client + while True: + data = socket.recv(1024) + if not data: + break + + # decode message for handling + message = data.decode() + message_json = json.loads(message) + print(f"received message from {address}: {message}") + + # decide which event should be performed + if message_json["event"] == "login": + # encode message and respond to client + # TODO: Handle login + response = f"" + socket.sendall(response.encode()) + elif message_json["event"] == "register": + # encode message and respond to client + # TODO: Handle registration + response = f"" + socket.sendall(response.encode()) + elif message_json["event"] == "logout": + # encode message and respond to client + # TODO: Handle registration + response = f"" + socket.sendall(response.encode()) + + # connection is not required anymore and gets closed + socket.close() + print(f"connection closed for {address}") + +# create tcp socket +server_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM) + +# make socket bind connection info and listen for connections +socket.bind(HOST, PORT) +socket.listen() +print(f"authorization server online on {HOST}:{PORT}") + +# server loop forwards connection to handle_connection +while True: + # accept incomming connection + # TODO: validate this connection is a valid game connection + client_socket, client_address = server_socket.accept() + + # create network thread for connection + client_thread = threading.Thread(target=handle_connection, args=(client_socket, client_address)) + client_thread.start() \ No newline at end of file diff --git a/TCG_Concept_server_infrastructure.drawio b/TCG_Concept_server_infrastructure.drawio new file mode 100644 index 0000000..742bece --- /dev/null +++ b/TCG_Concept_server_infrastructure.drawio @@ -0,0 +1,122 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..244463b --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,26 @@ +version: '3' + +services: + tcg_database: + image: postgres + restart: always + environment: + POSTGRES_PASSWORD: example + ports: + - 51346:5432 + database_visualizer: + image: adminer + restart: always + ports: + - 8080:8080 + redis_cache: + image: redis + restart: always + ports: + - 6379:6379 +volumes: + dbdata: + +networks: + shoplistnetwork: + driver: bridge \ No newline at end of file diff --git a/tcg_concept_card.png b/tcg_concept_card.png new file mode 100644 index 0000000..a80fb69 Binary files /dev/null and b/tcg_concept_card.png differ diff --git a/tcg_concept_card.psd b/tcg_concept_card.psd new file mode 100644 index 0000000..16c8c6e Binary files /dev/null and b/tcg_concept_card.psd differ diff --git a/tcg_concept_field.png b/tcg_concept_field.png new file mode 100644 index 0000000..68b4d99 Binary files /dev/null and b/tcg_concept_field.png differ diff --git a/tcg_concept_field.psd b/tcg_concept_field.psd new file mode 100644 index 0000000..e425460 Binary files /dev/null and b/tcg_concept_field.psd differ