44import requests
55import re
66import base64
7- import logging
7+ import logging
88from urllib .parse import unquote
99
1010app = Flask ("Secured Signal Api" )
@@ -76,18 +76,18 @@ def middlewares():
7676 auth_header = request .headers .get ("Authorization" , "" )
7777
7878 if auth_header .startswith ("Bearer " ):
79- token = auth_header .split (" " , 1 )[1 ]
80-
79+ token = auth_header .split (" " , 1 )[1 ]
80+
8181 token = unquote (token )
8282 if token != API_TOKEN :
8383 infoLog (f"Client failed Bearer Auth [token: { token } ]" )
84- return UnauthorizedResponse ()
84+ return UnauthorizedResponse ()
8585 elif auth_header .startswith ("Basic " ):
8686 try :
8787 decoded = base64 .b64decode (auth_header .split (" " , 1 )[1 ]).decode ()
88- username , password = decoded .split (":" , 1 )
89-
90- username = unquote (username )
88+ username , password = decoded .split (":" , 1 )
89+
90+ username = unquote (username )
9191 password = unquote (password )
9292 if username != "api" or password != API_TOKEN :
9393 infoLog (f"Client failed Basic Auth [user: { username } , pw:{ password } ]" )
@@ -169,4 +169,4 @@ def errorLog(msg):
169169 "RECIPIENTS" : DEFAULT_RECIPIENTS
170170 }
171171
172- app .run (debug = False , port = 8880 , host = '0.0.0.0' )
172+ app .run (debug = False , port = 8880 , host = '0.0.0.0' )
0 commit comments