mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-28 11:40:25 +00:00
fix: enforce authentication on unauthenticated endpoints and harden auth_must (#1294)
Co-authored-by: bytecii <994513625@qq.com>
This commit is contained in:
parent
1831d2a686
commit
8d26e1a122
4 changed files with 172 additions and 6 deletions
|
|
@ -89,9 +89,11 @@ async def auth(
|
|||
|
||||
|
||||
async def auth_must(
|
||||
token: str = Depends(oauth2_scheme),
|
||||
token: str | None = Depends(oauth2_scheme),
|
||||
session: Session = Depends(session),
|
||||
) -> Auth:
|
||||
if token is None:
|
||||
raise TokenException(code.token_invalid, _("Authentication required"))
|
||||
model = Auth.decode_token(token)
|
||||
user = session.get(User, model.id)
|
||||
model._user = user
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue