Skip to content

Commit 6847ca3

Browse files
committed
Drop banned request earlier
No point in wasting cycles doing auth validation if we're just going to drop the request anyway because the pubkey is banned.
1 parent d4b2c32 commit 6847ca3

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

sogs/routes/auth.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,10 @@ def handle_http_auth():
205205
)
206206

207207
user = User(session_id=pk, autovivify=True, touch=False)
208+
if user.banned:
209+
# If the user is banned don't even bother verifying the signature because we want to reject
210+
# the request whether or not the signature validation passes.
211+
abort_with_reason(http.FORBIDDEN, 'Banned', warn=False)
208212

209213
try:
210214
query('INSERT INTO user_request_nonces ("user", nonce) VALUES (:u, :n)', u=user.id, n=nonce)
@@ -240,8 +244,5 @@ def handle_http_auth():
240244
http.UNAUTHORIZED, "Invalid authentication: X-SOGS-Hash authentication failed"
241245
)
242246

243-
if user.banned:
244-
abort_with_reason(http.FORBIDDEN, 'Banned', warn=False)
245-
246247
user.touch()
247248
g.user = user

0 commit comments

Comments
 (0)