fetch private biomodels when the user is logged in - #79
Open
androemeda wants to merge 4 commits into
Open
Conversation
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.
Summary
Currently the backend fetches biomodels from VCell's legacy v0 API (
vcell.cam.uchc.edu/api/v0) without any credentials, so only public models are ever visible — regardless of whether the user is logged in. This PR adds an opt-in auth path: when a request carries a valid Auth0 bearer token, the backend exchanges it for a legacy VCell token (POST /api/v1/users/bearerToken) and forwards that to the v0 API, so logged-in users also see their private and shared biomodels. Logged-out requests are unaffected — v0 calls without a token behave exactly as before.Backend
core/auth.py: newget_optional_auth0_tokendependency — returnsNonewhen noAuthorizationheader is sent (public-only).vcelldb_service.py: newget_legacy_vcell_token()does the Auth0 → legacy token exchange.fetch_biomodels()andget_diagram_image()now take an optionalauth0_tokenand attach the exchanged legacy token asAuthorization: Beareron the v0 call when present.GET /biomodelandGET /biomodel/{id}/diagram/imagenow depend onget_optional_auth0_token./query(chat): the route now also resolves the raw access token and threads it throughllms_controller→llms_service.get_response_with_tools→tools_utils.execute_tool, so thefetch_biomodelstool call the chatbot makes also includes private/shared models when logged in.Frontend
lib/get-optional-access-token.ts— likegetAccessToken, but resolves toundefinedinstead of throwing when there's no session.search/page.tsx,search/[bmid]/page.tsx,analyze/[id]/page.tsxnow send the token (when available) on their/biomodel*fetches.