python imports hell
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
FROM harbor.k-space.ee/k-space/microservice-base
|
FROM harbor.k-space.ee/k-space/microservice-base:latest
|
||||||
RUN pip3 install httpx
|
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
COPY app /app
|
COPY app /app
|
||||||
CMD /app/doorboy-proxy.py
|
CMD ["python3", "/app/doorboy-proxy.py"]
|
||||||
|
@@ -11,11 +11,11 @@ from sanic import Sanic
|
|||||||
from sanic.response import json, text
|
from sanic.response import json, text
|
||||||
from sanic_prometheus import monitor
|
from sanic_prometheus import monitor
|
||||||
|
|
||||||
from .slack import add_slack_routes
|
import kube
|
||||||
from .users import users_with_group
|
import slack
|
||||||
|
|
||||||
app = Sanic(__name__)
|
app = Sanic(__name__)
|
||||||
add_slack_routes(app)
|
slack.add_routes(app)
|
||||||
monitor(app).expose_endpoint()
|
monitor(app).expose_endpoint()
|
||||||
|
|
||||||
# API key for godoor controllers authenticating to k-space:floor
|
# API key for godoor controllers authenticating to k-space:floor
|
||||||
@@ -61,9 +61,9 @@ async def view_doorboy_uids(request):
|
|||||||
# authorize
|
# authorize
|
||||||
key = request.headers.get("KEY")
|
key = request.headers.get("KEY")
|
||||||
if key == DOORBOY_SECRET_FLOOR:
|
if key == DOORBOY_SECRET_FLOOR:
|
||||||
users = users_with_group(FLOOR_ACCESS_GROUP)
|
users = kube.users_with_group(FLOOR_ACCESS_GROUP)
|
||||||
elif key == DOORBOY_SECRET_WORKSHOP:
|
elif key == DOORBOY_SECRET_WORKSHOP:
|
||||||
users = users_with_group(WORKSHOP_ACCESS_GROUP)
|
users = kube.users_with_group(WORKSHOP_ACCESS_GROUP)
|
||||||
else:
|
else:
|
||||||
print("WARN: unknown door token in /allowed")
|
print("WARN: unknown door token in /allowed")
|
||||||
return "unknown doorboy secret token", 403
|
return "unknown doorboy secret token", 403
|
||||||
|
@@ -1,14 +1,15 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
import requests
|
||||||
from pymongo.errors import PyMongoError
|
from pymongo.errors import PyMongoError
|
||||||
from requests.exceptions import RequestException
|
from requests.exceptions import RequestException
|
||||||
import os
|
|
||||||
import requests
|
|
||||||
|
|
||||||
# webhook logs to private channel or "DEV" to print to console.
|
# webhook logs to private channel or "DEV" to print to console.
|
||||||
SLACK_DOORLOG_CALLBACK = os.environ["SLACK_DOORLOG_CALLBACK"]
|
SLACK_DOORLOG_CALLBACK = os.environ["SLACK_DOORLOG_CALLBACK"]
|
||||||
|
|
||||||
|
|
||||||
def add_slack_routes(app):
|
def add_routes(app):
|
||||||
app.app.register_listener(slack_log, "after_server_start")
|
app.register_listener(slack_log, "after_server_start")
|
||||||
|
|
||||||
|
|
||||||
def slack_post(msg):
|
def slack_post(msg):
|
||||||
|
@@ -20,7 +20,6 @@ services:
|
|||||||
driver: none
|
driver: none
|
||||||
|
|
||||||
doorboy_proxy:
|
doorboy_proxy:
|
||||||
network_mode: host
|
|
||||||
environment:
|
environment:
|
||||||
DOORBOY_SECRET_FLOOR: "0123456789"
|
DOORBOY_SECRET_FLOOR: "0123456789"
|
||||||
DOORBOY_SECRET_WORKSHOP: "9999999999"
|
DOORBOY_SECRET_WORKSHOP: "9999999999"
|
||||||
@@ -28,5 +27,7 @@ services:
|
|||||||
WORKSHOP_ACCESS_GROUP: "k-space:workshop"
|
WORKSHOP_ACCESS_GROUP: "k-space:workshop"
|
||||||
SLACK_DOORLOG_CALLBACK: DEV
|
SLACK_DOORLOG_CALLBACK: DEV
|
||||||
env_file: .env
|
env_file: .env
|
||||||
|
ports:
|
||||||
|
- "5000:5000"
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
|
Reference in New Issue
Block a user