initial commit - added auth server

This commit is contained in:
steev 2023-12-04 13:38:21 +01:00
commit 48acef0436
8 changed files with 217 additions and 0 deletions

3
Auth Server/.env Normal file
View File

@ -0,0 +1,3 @@
HOST="127.0.0.1"
PORT=54321
ENV="DEV"

66
Auth Server/index.py Normal file
View File

@ -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"<place_holder_message>"
socket.sendall(response.encode())
elif message_json["event"] == "register":
# encode message and respond to client
# TODO: Handle registration
response = f"<place_holder_message>"
socket.sendall(response.encode())
elif message_json["event"] == "logout":
# encode message and respond to client
# TODO: Handle registration
response = f"<place_holder_message>"
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()

View File

@ -0,0 +1,122 @@
<mxfile host="app.diagrams.net" modified="2023-11-29T23:07:48.870Z" agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:120.0) Gecko/20100101 Firefox/120.0" etag="psuLae1D-KDIGV4GE2n6" version="22.1.4" type="device">
<diagram name="Seite-1" id="WQu0apHHyxKXUf0uEiYY">
<mxGraphModel dx="1434" dy="774" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="827" pageHeight="1169" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="7V57k1mWxqMw2Yh0PZKH-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-1" target="7V57k1mWxqMw2Yh0PZKH-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-19" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-1" target="7V57k1mWxqMw2Yh0PZKH-18">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-34" value="Requesting&lt;br&gt; Game" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-19">
<mxGeometry x="-0.3846" y="-3" relative="1" as="geometry">
<mxPoint x="20" y="-3" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-1" value="&lt;div&gt;Client&lt;/div&gt;" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="40" y="200" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-30" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0;exitDx=0;exitDy=52.5;exitPerimeter=0;entryX=0.25;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-2" target="7V57k1mWxqMw2Yh0PZKH-20">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-31" value="Respond&lt;br&gt;with&lt;br&gt;User&lt;br&gt;Data" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-30">
<mxGeometry x="0.2315" y="-2" relative="1" as="geometry">
<mxPoint y="62" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-2" value="&lt;div&gt;Database&lt;/div&gt;" style="shape=cylinder3;whiteSpace=wrap;html=1;boundedLbl=1;backgroundOutline=1;size=15;" vertex="1" parent="1">
<mxGeometry x="320" width="60" height="80" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-3" target="7V57k1mWxqMw2Yh0PZKH-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-6" value="&lt;div&gt;User Stats Lookup&lt;/div&gt;" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-4">
<mxGeometry x="0.05" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-3" value="User Management" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="40" y="20" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-13" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=1;exitY=0.75;exitDx=0;exitDy=0;entryX=0;entryY=1;entryDx=0;entryDy=-15;entryPerimeter=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-3" target="7V57k1mWxqMw2Yh0PZKH-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-15" value="User Request" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-13">
<mxGeometry x="0.1625" y="1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-14" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0;exitY=0;exitDx=0;exitDy=27.5;exitPerimeter=0;entryX=0.992;entryY=0.133;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-2" target="7V57k1mWxqMw2Yh0PZKH-3">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-16" value="User Data" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-14">
<mxGeometry x="-0.2568" y="-4" relative="1" as="geometry">
<mxPoint y="1" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-22" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-18" target="7V57k1mWxqMw2Yh0PZKH-20">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-35" value="Redirect&lt;br&gt;User&lt;br&gt;to&lt;br&gt;Server" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-22">
<mxGeometry x="-0.3455" relative="1" as="geometry">
<mxPoint x="14" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-18" value="Matchmaker" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="290" y="200" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.75;entryY=1;entryDx=0;entryDy=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-20" target="7V57k1mWxqMw2Yh0PZKH-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-26" value="Game Server Data Channeö" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-24">
<mxGeometry x="0.0522" y="-3" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-20" value="Game Server" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="520" y="200" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-25" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;exitX=0.25;exitY=1;exitDx=0;exitDy=0;entryX=0.875;entryY=1.017;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-1" target="7V57k1mWxqMw2Yh0PZKH-20">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="70" y="320" />
<mxPoint x="625" y="320" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-27" value="User Data Channel" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-25">
<mxGeometry x="-0.1335" y="-4" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-28" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-20" target="7V57k1mWxqMw2Yh0PZKH-2">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="580" y="40" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-29" value="Request &lt;br&gt;User&lt;br&gt;Data" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-28">
<mxGeometry x="-0.5278" y="-4" relative="1" as="geometry">
<mxPoint x="-4" y="-35" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-32" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=1;entryY=0.5;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="7V57k1mWxqMw2Yh0PZKH-20" target="7V57k1mWxqMw2Yh0PZKH-2">
<mxGeometry relative="1" as="geometry">
<Array as="points">
<mxPoint x="680" y="230" />
<mxPoint x="680" y="40" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="7V57k1mWxqMw2Yh0PZKH-33" value="Update&lt;br&gt;Game&lt;br&gt;State" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="7V57k1mWxqMw2Yh0PZKH-32">
<mxGeometry x="-0.4038" y="-1" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>

26
docker-compose.yml Normal file
View File

@ -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

BIN
tcg_concept_card.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

BIN
tcg_concept_card.psd Normal file

Binary file not shown.

BIN
tcg_concept_field.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
tcg_concept_field.psd Normal file

Binary file not shown.