add auth middleware

This commit is contained in:
2025-03-25 15:07:49 -03:00
parent 317c79cee2
commit cd6fdd58ad
12 changed files with 176 additions and 36 deletions

View File

@@ -5,13 +5,21 @@ ORDER_TABLE: str = os.getenv('ORDER_TABLE') # type: ignore
ENROLLMENT_TABLE: str = os.getenv('ENROLLMENT_TABLE') # type: ignore
COURSE_TABLE: str = os.getenv('COURSE_TABLE') # type: ignore
ELASTIC_CLOUD_ID = os.getenv('ELASTIC_CLOUD_ID')
ELASTIC_AUTH_PASS = os.getenv('ELASTIC_AUTH_PASS')
if {'AWS_SAM_LOCAL', 'ELASTIC_HOSTS'}.intersection(os.environ):
ELASTIC_CONN = {'hosts': 'http://host.docker.internal:9200'}
else:
ELASTIC_CONN = {
'cloud_id': ELASTIC_CLOUD_ID,
'basic_auth': ('elastic', ELASTIC_AUTH_PASS),
}
match (os.getenv('AWS_SAM_LOCAL'), os.getenv('ELASTIC_HOSTS')):
case (str() as AWS_SAM_LOCAL, _) if AWS_SAM_LOCAL:
ELASTIC_CONN = {
'hosts': 'http://host.docker.internal:9200',
}
case (_, str() as ELASTIC_HOSTS) if ELASTIC_HOSTS:
ELASTIC_CONN = {
'hosts': ELASTIC_HOSTS,
}
case _:
ELASTIC_CLOUD_ID = os.getenv('ELASTIC_CLOUD_ID')
ELASTIC_AUTH_PASS = os.getenv('ELASTIC_AUTH_PASS')
ELASTIC_CONN = {
'cloud_id': ELASTIC_CLOUD_ID,
'basic_auth': ('elastic', ELASTIC_AUTH_PASS),
}