Skip to content

Commit db3b9b8

Browse files
committed
Have the dummy backend handle unknown users safely
1 parent 7f63e7a commit db3b9b8

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

code_submitter/auth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,10 @@ def __init__(self, data: List[NemesisUserInfo] = DEFAULT) -> None:
203203
self.data = {x['username']: x for x in data}
204204

205205
async def load_user(self, username: str, password: str) -> NemesisUserInfo:
206-
return self.data[username]
206+
try:
207+
return self.data[username]
208+
except KeyError:
209+
raise AuthenticationError(f"Unknown user {username}") from None
207210

208211

209212
class FileBackend(BasicAuthBackend):

0 commit comments

Comments
 (0)