Skip to content

Commit 79fc32a

Browse files
authored
Merge pull request #518 from almarklein/localhost
Add check for localhost auth
2 parents c36f357 + 814940b commit 79fc32a

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

tests/test_config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def test_config():
99
# Defaults
10-
default_bind = "0.0.0.0:80"
10+
default_bind = "127.0.0.1:8080"
1111
set_config([], {})
1212
assert config.bind == default_bind
1313
assert config.datadir == "~/_timetagger"

timetagger/__main__.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,12 @@ async def get_webtoken_localhost(request, auth_info):
202202
"""An authentication handler that provides a webtoken when the
203203
hostname is localhost. See `get_webtoken_unsafe()` for details.
204204
"""
205-
205+
if not config.bind.startswith("127.0.0.1"):
206+
return (
207+
403,
208+
{},
209+
"Can only login via localhost if the server address (config.bind) is '127.0.0.1'",
210+
)
206211
# Don't allow localhost validation when proxy auth is enabled
207212
if config.proxy_auth_enabled:
208213
return 403, {}, "forbidden: disabled when proxy auth is available"

timetagger/_config.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def to_bool(value):
1313
class Config:
1414
"""Object that holds config values.
1515
16-
* `bind (str)`: the address and port to bind on. Default "0.0.0.0:80".
16+
* `bind (str)`: the address and port to bind on. Default "127.0.0.1:8080".
1717
* `datadir (str)`: the directory to store data. Default "~/_timetagger".
1818
The user db's are stored in `datadir/users`.
1919
* `log_level (str)`: the log level for timetagger and asgineer
@@ -43,7 +43,7 @@ class Config:
4343
"""
4444

4545
_ITEMS = [
46-
("bind", str, "0.0.0.0:80"),
46+
("bind", str, "127.0.0.1:8080"),
4747
("datadir", str, "~/_timetagger"),
4848
("log_level", str, "info"),
4949
("credentials", str, ""),

0 commit comments

Comments
 (0)