Skip to content

Commit 09cfdb4

Browse files
committed
added configurable user/pass
1 parent 7288fa6 commit 09cfdb4

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

API/APIServer.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ def __init__(self, trade_handler: TradeHandler):
2626
self.th = trade_handler
2727
self.app = app
2828

29-
self.app.config['JWT_SECRET_KEY'] = 'mHZ!?9@DzdLrn@H!gy2FD46W--M*Fap!' # Change this!
29+
self.app.config['JWT_SECRET_KEY'] = 'mHZ!?9@DzdLrn@H!gy2FD46W--M*Fap!' # TODO: Change this!
30+
self.app.config['SECRET_KEY'] = 'VS?cWpbD^CGa-M@h6+@pV#qCQRU3c4dn' # TODO: Change this!
3031
self.app.config['JWT_EXPIRES'] = timedelta(weeks=48)
31-
self.app.config['SECRET_KEY'] = 'VS?cWpbD^CGa-M@h6+@pV#qCQRU3c4dn'
3232

3333
self.jwt = JWTManager(app)
3434

API/Endpoints/JWTEndpoint.py

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1+
import os
12
from calendar import timegm
2-
from datetime import datetime, timedelta
3+
from datetime import datetime
34

45
import flask
56
from flask import request
@@ -10,6 +11,9 @@
1011

1112

1213
class JWTEndpoint(BotAPIResource):
14+
user: str = os.getenv('API_USER', 'bot')
15+
pwd: str = os.getenv('API_PASS', 'botpwd')
16+
1317
def __init__(self, trade_handler):
1418
super().__init__(trade_handler)
1519

@@ -28,7 +32,7 @@ def post(self):
2832
if not password:
2933
return APIResult.ErrorResult(status=101, msg="Missing password parameter"), 400
3034

31-
if username != 'test' or password != 'test':
35+
if username != JWTEndpoint.user or password != JWTEndpoint.pwd:
3236
return APIResult.ErrorResult(status=101, msg="Bad username or password"), 401
3337

3438
# Identity can be any data that is json serializable

0 commit comments

Comments
 (0)