Authentication fixes
All checks were successful
buildbot/multibuild_parent Build done.
buildbot/travis_bionic Build done.

This commit is contained in:
Peter Šurda 2023-12-04 16:56:04 +08:00
parent 2467612e42
commit 8df8de76fc
Signed by: PeterSurda
GPG Key ID: 3E47497CF67ABB95

View File

@ -49,7 +49,7 @@ def process_combined(combined):
return cal.to_ical()
def get_token(input_token):
token = input_token.lstrip("Basic ")
token = input_token.removeprefix("Basic ")
token = b64decode(token).decode('utf8', 'ignore')
with cherrypy.HTTPError.handle(ValueError, 401):
_, token = token.split(":", 2)
@ -58,6 +58,8 @@ def get_token(input_token):
class Root:
@cherrypy.expose
def todo(self):
cherrypy.response.headers['WWW-Authenticate'] = \
'Basic realm="ICS access"'
authorization = cherrypy.request.headers.get('Authorization', ':')
if not authorization:
raise cherrypy.HTTPError(401, 'Unauthorized')