From e229c63e11b6468c4915aa1f0fec4e21a7c40cd9 Mon Sep 17 00:00:00 2001 From: Min RK Date: Wed, 25 May 2022 15:53:48 +0200 Subject: [PATCH] use equality to filter token prefixes otherwise, index isn't used note: this means changing the token prefix size requires revoking all tokens, where before only _increasing_ the token prefix size required doing that. --- jupyterhub/orm.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/jupyterhub/orm.py b/jupyterhub/orm.py index b30b8040..b8a45af3 100644 --- a/jupyterhub/orm.py +++ b/jupyterhub/orm.py @@ -528,9 +528,7 @@ class Hashed(Expiring): prefix = token[: cls.prefix_length] # since we can't filter on hashed values, filter on prefix # so we aren't comparing with all tokens - prefix_match = db.query(cls).filter( - bindparam('prefix', prefix).startswith(cls.prefix) - ) + prefix_match = db.query(cls).filter_by(prefix=prefix) prefix_match = prefix_match.filter( or_(cls.expires_at == None, cls.expires_at >= cls.now()) )