Is there any documentation for allowing the agent ...
# ask-ai
l
Is there any documentation for allowing the agent to securely access data without giving it access to data it shouldn't? like how to make sure the agent can't access data from other users or anything
t
Thanks for reaching out, M. I'm an AI assistant and I'm here to help. Give me a moment while I research this topic.
To help you securely allow an agent to access data without any unauthorized access, LiveKit offers a token-based authentication system with fine-grained access controls. Let me walk you through the key steps: • Use Short-Lived Tokens: It’s best to generate short-lived JSON Web Tokens (JWTs) that include only the permissions your agent truly needs for their role. • Define Minimal Grants: Using
VideoGrant
helps you clearly specify permissions, like which rooms they can access and what publishing rights they have. • Assign Agent Role: When creating the token, set the participant kind to "agent" so everything routes correctly and the agent’s identity is clear. • Logical Data Segregation: Make sure data is tagged with unique identifiers to keep everything separated and avoid any cross-customer access. • Secure Configuration: It’s important to avoid putting sensitive credentials inside tokens and to limit grants like SIP or inference only to authorized services. If you’d like, I’m happy to provide detailed examples or clarify any of these steps further. Just let me know how I can assist! Sources: client/web/src/app/api/connection-details/route.ts | complex-agents/nova-sonic/nova-sonic-form-agent/app/api/connection-details/... | livekit-api/livekit/api/access_token.py | LiveKit | auth/grants.go
l
where should credentials for external databases be passed? are the JWTs sent to the client or the agent?
t
To keep your credentials for external databases safe, it's best to use LiveKit's secrets management system. This way, sensitive information is encrypted and securely stored, then provided to agent containers as environment variables when they run. If you're working locally, using a
.env.local
file is a great approach—just remember to keep it out of version control to protect your data. When it comes to JWTs, these are created on the server side and sent to client SDKs to authenticate participants. Agents themselves don’t get JWTs directly, but they might receive some related context like job or room metadata to help with their tasks. If you’d like, I’m here to walk you through these steps or provide more details to make sure everything goes smoothly for you. Sources: complex-agents/nutrition-assistant/nutrition-assistant-frontend/app/api/con... | Secrets management | LiveKit Docs | External data and RAG | LiveKit Docs | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki
l
For example, if I want my livekit agent to be able to do queries against a firestore db on behalf of my user, but only have access to data the the user should have access to, where should firestore access tokens go? I don't want to give the agent full access to the database. This means that the agent needs to receive the access token on initialization. Where should these tokens go?
t
To help you securely pass Firestore access tokens to a LiveKit agent for user-specific queries, you can use job metadata or participant attributes to include user-specific identifiers or secure references. Let me walk you through how you can set this up: • Use Job Metadata: You can pass user-specific information (like user ID or token exchange endpoint) in the job metadata when dispatching the agent. This way, the agent can retrieve this metadata and safely perform a token exchange with your backend to get a scoped Firestore token. • Secure Token Exchange: It’s a great idea to implement a backend service that validates the agent’s request, issues Firestore tokens with minimal permissions, and ensures they expire quickly (for example, after 15 minutes). • Participant Attributes: Another option is to include user-specific attributes in the participant token. The agent can then use this info to identify the user and request a scoped token securely. If you’d like, I’m happy to provide detailed examples on how to configure job metadata or how to implement the token exchange process. Just let me know! Sources: app/api/connection-details/route.ts | Authentication | LiveKit Docs | LiveKit Security | Server-Side SDKs & Authentication | livekit/livekit_composite | DeepWiki | External data and RAG | LiveKit Docs
l
is the job metadata or user specific attributes in the participant token accessible by participants?
t
I wanted to share some important info about participant metadata and user-specific attributes in LiveKit. These details included in the participant token are accessible to everyone in the same LiveKit room, as LiveKit keeps everything synchronized automatically. Currently, there aren’t any built-in privacy settings to limit who can see this data. So, if you’re dealing with sensitive information, it’s best to avoid putting it directly into participant metadata or attributes. A safer approach would be to use secure backend communication to send sensitive data straight to the agent, without embedding it in tokens or metadata. If you’d like, I’m here to help you with setting up these secure data handling practices or answer any other questions you might have! Sources: Participant attributes and metadata | LiveKit docs | test/multinode_test.go | Rooms, participants, and tracks | LiveKit docs