tl  tr
  Home | Tutorials | Articles | Videos | Products | Tools | Search
Interviews | Open Source | Tag Cloud | Follow Us | Bookmark | Contact   
 Generative AI > Google Gemini API > ADK Role-Based Access Control

ADK Role-Based Access Control

Author: Venkata Sudhakar

Role-Based Access Control (RBAC) in ADK ensures that different users get different agent capabilities based on their assigned role. A ShopMax India store manager can view orders and trigger refunds, while a sales associate can only view orders. The agent enforces these boundaries at the tool layer � roles are checked before any tool is executed.

The pattern uses a role guard decorator that wraps each tool function. The decorator reads the user role from session state (set during authenticated login) and raises an error if the role lacks the required permission. This keeps authorisation logic out of the agent instruction and makes it tamper-resistant.

The below example shows a ShopMax agent with three tools gated by role: viewer, manager, and admin.


It gives the following output,

Viewer:   Sorry, you do not have permission to process refunds. Your role is "viewer".
Manager:  Refund of Rs 3,200 for ORD-101 has been queued successfully.
Admin:    Order ORD-103 has been deleted from the system.

In production, store role assignments in Firestore or Cloud Spanner and load them into session state during the authentication handshake. Combine RBAC with Cloud IAM so the service account backing each role only has BigQuery or Pub/Sub permissions matching that role. Audit all permission denials to Cloud Logging for compliance reporting.


 
  


  
bl  br