mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-28 05:27:35 +00:00
fix: SQLite OAuth overflow for 21-digit Google sub IDs
Prevents int() overflow on 21-digit Google OAuth sub values by comparing as string only when number exceeds SQLite INTEGER (64-bit) limit. Closes #29048
This commit is contained in:
parent
56d296ef1b
commit
c6a9ad7549
1 changed files with 8 additions and 1 deletions
|
|
@ -367,7 +367,14 @@ class UsersTable:
|
|||
query = select(User).where(sub_expr == sub)
|
||||
# SQLite preserves JSON numeric type here; Postgres ->> already compares numeric JSON as text.
|
||||
if session.get_bind().dialect.name == 'sqlite' and sub.isdecimal():
|
||||
query = select(User).where(or_(sub_expr == sub, sub_expr == int(sub)))
|
||||
try:
|
||||
int_sub = int(sub)
|
||||
if len(sub) <= 19:
|
||||
query = select(User).where(or_(sub_expr == sub, sub_expr == int_sub))
|
||||
else:
|
||||
query = select(User).where(sub_expr == sub)
|
||||
except ValueError:
|
||||
query = select(User).where(sub_expr == sub)
|
||||
row = (await session.execute(query)).scalars().first()
|
||||
return UserModel.model_validate(row) if row else None
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue