Skip to content

Commit

Permalink
Merge pull request #187 from multiflexi/update_bots
Browse files Browse the repository at this point in the history
Update bots
  • Loading branch information
milankowww authored Nov 29, 2023
2 parents 4fed126 + 223ddb6 commit a70a9fa
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
4 changes: 2 additions & 2 deletions docker/Dockerfile.bots
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.7-alpine3.14 AS build_shared
FROM python:3.12-alpine3.18 AS build_shared

WORKDIR /build_shared/

Expand All @@ -8,7 +8,7 @@ RUN python -m build



FROM python:3.7-alpine3.14 AS production
FROM python:3.12-alpine3.18 AS production

WORKDIR /app/

Expand Down
22 changes: 17 additions & 5 deletions src/bots/managers/auth_manager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""Authorization manager for the API.
Returns:
wrapper: Wrapper function for the API endpoints.
"""
from functools import wraps
from flask import request
import os
import ssl

api_key = os.getenv('API_KEY')
api_key = os.getenv("API_KEY")

if os.getenv('SSL_VERIFICATION') == "False":
if os.getenv("SSL_VERIFICATION") == "False":
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
Expand All @@ -15,11 +20,18 @@


def api_key_required(fn):
"""Check for API key in the request header.
Arguments:
fn -- The function to be decorated.
Returns:
wrapper: Wrapper function for the API endpoints.
"""

@wraps(fn)
def wrapper(*args, **kwargs):

if not request.headers.has_key('Authorization') or request.headers['Authorization'] != ('Bearer ' + api_key):
return {'error': 'not authorized'}, 401
if "Authorization" not in request.headers.keys() or request.headers["Authorization"] != ("Bearer " + api_key):
return {"error": "not authorized"}, 401
else:
return fn(*args, **kwargs)

Expand Down
35 changes: 11 additions & 24 deletions src/bots/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,26 +1,13 @@
certifi==2019.11.28
Flask==1.1.4
Flask-Cors==3.0.10
Flask-RESTful==0.3.7
gevent==21.8.0
greenlet==1.1.1
gunicorn==20.0.4
idna==2.8
marshmallow==3.18.0
Flask==3.0.0
Flask-Cors==4.0.0
Flask-RESTful==0.3.10
gevent==23.9.1
gunicorn==21.2.0
marshmallow==3.20.1
marshmallow-enum==1.5.1
Jinja2==2.11.3
MarkupSafe==1.1.0
oauthlib==3.1.0
oauthlib==3.2.2
PySocks==1.7.1
python-dateutil==2.8.1
python-dotenv==0.10.5
pytz==2019.3
requests==2.26.0
requests-oauthlib==1.3.0
schedule==0.6.0
six==1.14.0
sseclient-py==1.7
tweepy==3.8.0
urllib3==1.26.7
Werkzeug==0.16.0
zipp==3.1.0
python-dotenv==1.0.0
requests==2.31.0
schedule==1.2.1
sseclient-py==1.8.0

0 comments on commit a70a9fa

Please sign in to comment.