mirror of
https://github.com/langchain-ai/langserve.git
synced 2026-07-18 10:54:29 -04:00
🔒 Easier Auth -- I'd like to pass a fastapi dependency to the add_routes method to secure them #80
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @randypitcherii on GitHub (Dec 30, 2023).
Originally assigned to: @eyurtsev on GitHub.
This is related to #294 -- fastapi dependency support lets me use swagger, but I'd still be blocked from securely accessing the playground until playground code supports auth headers.
Thanks! 🙏
@eyurtsev commented on GitHub (Jan 1, 2024):
@randypitcherii thanks for reporting! This makes sense.
For now, if you should be able to achieve that using the
APIHandlerobject. See example here: https://github.com/langchain-ai/langserve/blob/main/examples/api_handler_examples/server.py@randypitcherii commented on GitHub (Jan 1, 2024):
This helps a ton!! Thank you : )
@eyurtsev commented on GitHub (Jan 3, 2024):
Added an ability to pass path dependencies to
add_routes.Examples using global dependencies and path dependencies have been added here: https://github.com/langchain-ai/langserve/tree/main/examples/auth
Neither of these options allows to do anything with the return value from the dependency as might be required to do implement logic specific to a particular user.
For those use cases, the best way right now is either using:
APIHandlerprimtiives@eyurtsev commented on GitHub (Jan 5, 2024):
Path dependencies are available here: https://github.com/langchain-ai/langserve/releases/tag/v0.0.38
@eyurtsev commented on GitHub (Jan 5, 2024):
Added some examples to the README for Auth: https://github.com/langchain-ai/langserve?tab=readme-ov-file#advanced
@randypitcherii Could you let me know if you encounter any issues on existing endpoints (except for playground)?