Skip to content

Commit

Permalink
Log redirects; fix login socket URL format bug (#28)
Browse files Browse the repository at this point in the history
* Log redirects; fix login socket URL format bug

* Bump version
  • Loading branch information
m4wh6k authored Nov 11, 2022
1 parent b5ed28f commit 72499bd
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.7.7
0.7.8
11 changes: 8 additions & 3 deletions src/boardwalkd/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,11 @@ def prepare(self):
req_url = urlparse(self.request.full_url())
svr_url: ParseResult = self.settings["url"]
if req_url.scheme != svr_url.scheme or req_url.netloc != svr_url.netloc:
req_url = req_url._replace(scheme=svr_url.scheme, netloc=svr_url.netloc)
return self.redirect(req_url.geturl())
redir_url = req_url._replace(scheme=svr_url.scheme, netloc=svr_url.netloc)
app_log.info(
f"Redirecting request {req_url.geturl()} to {redir_url.geturl()}"
)
return self.redirect(redir_url.geturl())

def get_current_user(self) -> bytes | None:
"""Required method for @tornado.web.authenticated to work"""
Expand Down Expand Up @@ -382,7 +385,9 @@ def id_client() -> str:

this_client_id = id_client()
app_log.info(f"Login client ID {this_client_id} opened")
login_url = f"{self.settings['url']}/api/auth/login?id={this_client_id}"
login_url = urljoin(
self.settings["url"].geturl(), f"/api/auth/login?id={this_client_id}"
)
return self.write_message(ApiLoginMessage(login_url=login_url).dict())

def on_close(self):
Expand Down

0 comments on commit 72499bd

Please sign in to comment.