Добавил возможность указывать токен через переменную среды
This commit is contained in:
13
main.py
13
main.py
@@ -32,12 +32,13 @@ def get_db():
|
||||
security = HTTPBearer()
|
||||
|
||||
|
||||
TOKEN: str = None
|
||||
THIS_SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
with open(os.path.join(THIS_SCRIPT_PATH, "token.json"), 'r') as f:
|
||||
t = json.load(f)
|
||||
TOKEN = t["auth.token"]
|
||||
|
||||
TOKEN: str = os.environ.get("BUILD_INC_TOKEN", None)
|
||||
if TOKEN is None:
|
||||
THIS_SCRIPT_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||
with open(os.path.join(THIS_SCRIPT_PATH, "token.json"), 'r') as f:
|
||||
t = json.load(f)
|
||||
TOKEN = t["auth.token"]
|
||||
|
||||
|
||||
def get_current_user(credentials: HTTPAuthorizationCredentials = Security(security)):
|
||||
if credentials.credentials != TOKEN:
|
||||
|
||||
Reference in New Issue
Block a user