Set `user` when deploying a webUI
Currently whenever you deploy using either the $adk commands or using the get_fast_api_app, all users who test the application are all labeled as 'user' in the Session/Memory instances (with I believe the exception of deployments via Agent Engine).
I would love to see support for being able to set the current user. I've brainstormed a few ways this could be implemented using the FastAPI App:
- Implement a
get_userfunction input toget_fast_api_app()- Would be the simplest way - every time a new session is created or retrieved, this function would be called to get the current user.
- Allows for a wide variety of integrations depending on deployment scenarios
- Implement a callback url that sets the user in the browser session
- If I deploy this and put an OAuth screen in front of this, let me have the callback url go to
/api/user-callbackwith a payload and it will set and use the user_id returned in the payload
- If I deploy this and put an OAuth screen in front of this, let me have the callback url go to
- Integrate with Google Cloud IAP
- https://cloud.google.com/iap/docs/identity-howto
- Cloud Run IAP is in preview, but GKE IAP is not.
- Would be simple to check and would encourage people to deploy on GCP if authentication is simple
Context
Lastly, it would be nice if there was an easy way to set the
userfor a session. We're currently using IAP with a Cloud Run deployment. I'm thinking if we could pass aget_userfunction to theget_fast_api_appthat could return the current user, then we can provide a way for the app to look up the current user ourselves. This would make it easier for many different deployment types to have a way to separate users.@dylan-apex great feedback. Do you mind creating a issue for us to track? Thanks.
Originally posted by @hangfei in #2133
@wyf7107 @DeanChensj Could you help review if this is something we should add, and if the community can contribute?