1
0
mirror of https://github.com/falk-werner/webfuse synced 2026-03-02 03:40:24 +00:00

webfuse-server: add header-based authentication

This commit is contained in:
Falk Werner
2023-01-15 14:55:31 +01:00
parent f12f461154
commit 8c290b8c02
10 changed files with 198 additions and 6 deletions

13
script/authenticator.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/usr/bin/bash
AUTH_TOKEN="$1"
if [[ "$AUTH_TOKEN" == "user:bob;token=foo" ]]
then
echo "$(date): webfuse: auth granted: $AUTH_TOKEN" >> /tmp/webfuse_auth.log
else
echo "$(date): webfuse: auth denied: $AUTH_TOKEN" >> /tmp/webfuse_auth.log
exit 1
fi

View File

@@ -272,7 +272,7 @@ class FilesystemProvider:
}
async def run(self):
async with websockets.connect(self.url) as connection:
async with websockets.connect(self.url, extra_headers=[("X-Auth-Token", "user:bob;token=foo")]) as connection:
while True:
request = await connection.recv()
reader = MessageReader(request)