Skip to content

Commit

Permalink
Add check for localhost login
Browse files Browse the repository at this point in the history
  • Loading branch information
almarklein committed Dec 16, 2024
1 parent c36f357 commit ec65d1d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
3 changes: 2 additions & 1 deletion timetagger/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ async def get_webtoken_localhost(request, auth_info):
"""An authentication handler that provides a webtoken when the
hostname is localhost. See `get_webtoken_unsafe()` for details.
"""

if not config.bind.startswith("127.0.0.1"):
return 403, {}, "Can only login via localhost if the server address (config.bind) is '127.0.0.1'"
# Don't allow localhost validation when proxy auth is enabled
if config.proxy_auth_enabled:
return 403, {}, "forbidden: disabled when proxy auth is available"
Expand Down
4 changes: 2 additions & 2 deletions timetagger/_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def to_bool(value):
class Config:
"""Object that holds config values.
* `bind (str)`: the address and port to bind on. Default "0.0.0.0:80".
* `bind (str)`: the address and port to bind on. Default "127.0.0.1:8080".
* `datadir (str)`: the directory to store data. Default "~/_timetagger".
The user db's are stored in `datadir/users`.
* `log_level (str)`: the log level for timetagger and asgineer
Expand Down Expand Up @@ -43,7 +43,7 @@ class Config:
"""

_ITEMS = [
("bind", str, "0.0.0.0:80"),
("bind", str, "127.0.0.1:8080"),
("datadir", str, "~/_timetagger"),
("log_level", str, "info"),
("credentials", str, ""),
Expand Down

0 comments on commit ec65d1d

Please sign in to comment.