Skip to content

Commit

Permalink
fix: avoid UUID for auth endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahwooders committed Aug 26, 2024
1 parent f2dfa79 commit c906b4d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
13 changes: 7 additions & 6 deletions memgpt/server/rest_api/auth/index.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from typing import Optional
from uuid import UUID

from fastapi import APIRouter
from pydantic import BaseModel, Field
Expand All @@ -12,8 +11,9 @@
router = APIRouter()


# TODO: remove these and add them to schemas?
class AuthResponse(BaseModel):
uuid: UUID = Field(..., description="UUID of the user")
user_id: str = Field(..., description="ID of the user")
is_admin: Optional[bool] = Field(None, description="Whether the user is an admin")


Expand All @@ -28,16 +28,17 @@ def authenticate_user(request: AuthRequest) -> AuthResponse:
"""
Authenticates the user and sends response with User related data.
Currently, this is a placeholder that simply returns a UUID placeholder
"""
interface.clear()

is_admin = False
if request.password != password:
response = server.api_key_to_user(api_key=request.password)
user_id = server.api_key_to_user(api_key=request.password)
return user_id
else:
is_admin = True
response = server.authenticate_user()
return AuthResponse(uuid=response, is_admin=is_admin)
user_id = server.authenticate_user()
return None
return AuthResponse(user_id=user_id, is_admin=is_admin)

return router
3 changes: 2 additions & 1 deletion memgpt/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,8 @@ def delete_agent(self, user_id: str, agent_id: str):

def authenticate_user(self) -> str:
# TODO: Implement actual authentication to enable multi user setup
return str(MemGPTConfig.load().anon_clientid)
# NOTE: THIS IS NASTY, GET RID OF IT SOON
return "user-" + str(MemGPTConfig.load().anon_clientid)

def api_key_to_user(self, api_key: str) -> str:
"""Decode an API key to a user"""
Expand Down

0 comments on commit c906b4d

Please sign in to comment.