Skip to content

Commit

Permalink
Merge pull request #186 from multiflexi/update_publishers
Browse files Browse the repository at this point in the history
Update publishers
  • Loading branch information
milankowww authored Nov 29, 2023
2 parents 430e19c + e274e78 commit 4fed126
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 35 deletions.
8 changes: 4 additions & 4 deletions docker/Dockerfile.publishers
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM python:3.9-alpine3.17 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.9-alpine3.17 AS production
FROM python:3.12-alpine3.18 AS production

WORKDIR /app/

Expand All @@ -25,9 +25,9 @@ RUN pip install --no-cache-dir ./custom_packages/taranis_ng_shared-*.whl && rm -

COPY ./src/publishers/requirements.txt /app/requirements.txt
RUN apk add --no-cache \
swig\
swig \
libmagic \
gnupg
gnupg

RUN \
apk add --no-cache --virtual .build-deps build-base \
Expand Down
22 changes: 17 additions & 5 deletions src/publishers/managers/auth_manager.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
"""Authentication manager for the API.
Returns:
_type_: _description_
"""
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 if the API key is valid.
Args:
fn (function): _description_
Returns:
_type_: _description_
"""

@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 or request.headers["Authorization"] != ("Bearer " + api_key):
return {"error": "not authorized"}, 401
else:
return fn(*args, **kwargs)

Expand Down
38 changes: 12 additions & 26 deletions src/publishers/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,29 +1,15 @@
certifi==2023.5.7
envelope==2.0.2
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
httplib2==0.22.0
idna==2.9
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
oauth2client==4.1.3
Jinja2==2.11.3
M2Crypto==0.38.0
MarkupSafe==1.1.0
paramiko==3.2.0
python-dateutil==2.8.1
python-dotenv==0.10.3
pytz==2019.3
requests==2.26.0
schedule==0.6.0
six==1.13.0
tweepy==3.10.0
urllib3==1.26.7
Werkzeug==0.16.0
zope.event==4.4
zope.interface==5.1.0
pymisp==2.4.128
paramiko==3.3.1
python-dotenv==1.0.0
requests==2.31.0
tweepy==4.14.0
urllib3==2.0.6
pymisp==2.4.128

0 comments on commit 4fed126

Please sign in to comment.