Add security to FastAPIAdapter - #442
Merged
Merged
Conversation
davorrunje
approved these changes
Oct 23, 2024
| f"Message in subject 'chat.server.initiate_chat': {body=} -> from process id {os.getpid()}" | ||
| ) | ||
| user_id = body.user_id.hex if body.user_id else "None" | ||
| user_id = body.user_id.hex if body.user_id else "None" # type: ignore |
| "watchfiles==0.24.0", | ||
| "email-validator==2.2.0", | ||
| "python-multipart>=0.0.12", | ||
| "PyJWT>=2.9.0", |
Contributor
There was a problem hiding this comment.
Suggested change
| "PyJWT>=2.9.0", | |
| "PyJWT==2.9.0", |
| @@ -149,6 +149,8 @@ testing = [ | |||
| "watchfiles==0.24.0", | |||
| "email-validator==2.2.0", | |||
| "python-multipart>=0.0.12", | |||
Contributor
There was a problem hiding this comment.
Suggested change
| "python-multipart>=0.0.12", | |
| "python-multipart==0.0.12", |
| "email-validator==2.2.0", | ||
| "python-multipart>=0.0.12", | ||
| "PyJWT>=2.9.0", | ||
| "passlib[bcrypt]>=1.7.4", |
Contributor
There was a problem hiding this comment.
Suggested change
| "passlib[bcrypt]>=1.7.4", | |
| "passlib[bcrypt]==1.7.4", |
| def get_user_id_depends( | ||
| user_id: Optional[str] = Depends(self.get_user_id), | ||
| ) -> Optional[str]: | ||
| return user_id |
Contributor
There was a problem hiding this comment.
Suggested change
| return user_id | |
| raise RuntimeError("should never be called") # pragma: no cover |
|
|
||
| self.router = self.setup_routes() | ||
|
|
||
| async def get_user_id_websocket(self, websocket: WebSocket) -> Optional[UUID]: |
Contributor
There was a problem hiding this comment.
Suggested change
| async def get_user_id_websocket(self, websocket: WebSocket) -> Optional[UUID]: | |
| async def get_user_id_websocket_stub(self, websocket: WebSocket) -> Optional[UUID]: |
| ) -> Optional[str]: | ||
| return user_id | ||
|
|
||
| dependant = get_dependant(path="", call=get_user_id_depends) |
Contributor
There was a problem hiding this comment.
Suggested change
| dependant = get_dependant(path="", call=get_user_id_depends) | |
| dependant = get_dependant(path="", call=get_user_id_websocket_stub) |
|
|
||
| class InitiateWorkflowModel(BaseModel): | ||
| user_id: Optional[UUID] = None | ||
| user_id: Optional[Union[UUID, str]] = None |
Contributor
There was a problem hiding this comment.
Suggested change
| user_id: Optional[Union[UUID, str]] = None | |
| user_id: Optional[str] = None |
| To use JWT tokens, you need to install [PyJWT](https://pyjwt.readthedocs.io/en/stable/) and [passlib](https://passlib.readthedocs.io/en/stable/) in addition to fastagency. | ||
|
|
||
| ```console | ||
| pip install "fastagency[autogen,mesop,fastapi,server]" |
davorrunje
approved these changes
Oct 23, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Type of change
Checklist