slight adjustments to prepare the authentification validation

This commit is contained in:
scopesorting 2024-01-19 17:33:43 +01:00 committed by Max Metz
parent 50e9261267
commit 39fbe67938
4 changed files with 17 additions and 5 deletions

View File

@ -14,7 +14,16 @@ bp = Blueprint('shipcalls', __name__)
@auth_guard() # no restriction by role
def GetShipcalls():
if 'Authorization' in request.headers:
token = request.headers.get('Authorization')
token = request.headers.get('Authorization') # see impl/login to see the token encoding, which is a JWT token.
"""
from BreCal.services.jwt_handler import decode_jwt
jwt = token.split('Bearer ')[1] # string key
payload = decode_jwt(jwt) # dictionary, which includes 'id' (user id) and 'participant_id'
# oneline:
payload = decode_jwt(request.headers.get("Authorization").split("Bearer ")[-1])
"""
options = {}
options["participant_id"] = request.args.get("participant_id")
options["past_days"] = request.args.get("past_days", default=1, type=int)

View File

@ -1,4 +1,4 @@
from enum import Enum, IntFlag
from enum import IntEnum, Enum, IntFlag
class ParticipantType(IntFlag):
"""determines the type of a participant"""
@ -36,3 +36,6 @@ class StatusFlags(Enum):
YELLOW = 2
RED = 3
class PierSide(IntEnum):
PORTSIDE = 0 # Port/Backbord
STARBOARD_SIDE = 1 # Starboard / Steuerbord

View File

@ -16,7 +16,7 @@ def initPool(instancePath):
print (config_path)
if not os.path.exists(config_path):
print ('cannot find ' + config_path)
print ('cannot find ' + os.path.abspath(config_path))
print("instance path", instancePath)
sys.exit(1)
@ -39,4 +39,4 @@ def getPoolConnection():
global config_path
f = open(config_path);
connection_data = json.load(f)
return mysql.connector.connect(**connection_data)
return mysql.connector.connect(**connection_data)

View File

@ -230,7 +230,7 @@ class Shipcall:
tug_required: bool
pilot_required: bool
flags: int
pier_side: bool
pier_side: bool # enumerator object in database/enum/PierSide
bunkering: bool
replenishing_terminal: bool
replenishing_lock: bool