Many customers have asked for fine-grained access to develop API Proxies and Shared Flows that allows development teams to work privately and to control access to specific environments. This solution guide provides a step-by-step solution that works nicely for both Apigee APIs and in the Apigee management console.
See also RBAC with Fine Grained Access - Apigee X - Using Groups.
As a security stakeholder, I want to restrict access to Apigee resources so that I can assign them to separate business units or projects.
Apigee supports adding resource conditions in IAM policies to these supported resources types using conditional role bindings during role assignment. Conditions can be based on time (e.g. schedule, expiry) or a named resource (e.g. type and name starts with “bu1-”). Roles can be assigned to individual users or to a group.
TIP: Assigning conditional access to a group simplifies management as once the conditions have been specified for the group, individual users are simply added to the group. This avoids updating the conditions on every user assignment.
NOTE: This guide uses a single user role assignment in a project, but the steps are similar when using a group in an organization.
Environments do not support conditional role assignment directly. Rather, access to an environment and its resources is granted via “Access” in the UI or via the Apigee API Environments Set IAM Policy API. Assigning a user as an “Apigee Environment Admin” to an environment (e.g. bu1-test) controls access to environment specific resources such as KVMs, Resource files, TargetServers, References, and KeyStores. It also controls access to deployments and debug sessions for the environment.
These resource types do not support “conditional” role based assignment, access to these resources can be managed via built in roles or custom roles.
Using GCP IAM Console or GCP APIs:
Using Apigee UI or Apigee APIs:
Apigee supports adding resource conditions in IAM policies on specific resource types (proxies, shared flows) used in the Apigee builtin rules through GCP IAM. Not all resource types are “conditional”, in particular Environments. Access to environments is done via “Access” in the UI or via the Apigee API Environments Set IAM Policy API. Assigning a user as an “Apigee Environment Admin” to an environment (e.g. bu1-test) controls access to environment specific resources such as KVMs, Resource files, TargetServers, References, and KeyStores.
This is required to allow the user to manage deployments and debug sessions in the Apigee UI. It also enables configuring Flow Hooks, for the assigned environment.
Create a custom role (e.g. Custom Role Apigee Deploy and Debug) that allows get and list permissions on deployments and environments.
apigee.deployments.get
apigee.deployments.list
apigee.entitlements.get
apigee.envgroupattachments.get
apigee.envgroupattachments.list
apigee.envgroups.get
apigee.envgroups.list
apigee.environments.get
apigee.environments.getStats
apigee.environments.list
apigee.operations.get
apigee.operations.list
apigee.projectorganizations.get
apigee.setupcontexts.get
The Apigee built in roles for Apigee API Admin and Apigee Developer Admin are required for an “API proxy developer” to create and test proxies and shared flows. Apigee API Admin role is required to create API proxies, shared flows and related artifacts such as API Products. Apigee Developer Admin role is required to create Developers and Apps for testing.
Add the following conditions to both the Apigee API Admin and Apigee Developer Admin role assignments.
NOTE: the resource.name.startsWith() condition uses the name of the project (e.g. apigeex-exp).
resource.name.startsWith("organizations/apigeex-exp/apis/bu1-") ||
resource.name.startsWith("organizations/apigeex-exp/sharedflows/bu1-") ||
resource.name.startsWith("organizations/apigeex-exp/apiproducts/bu1-") ||
(resource.type == 'apigee.googleapis.com/Developer') ||
(resource.type == 'apigee.googleapis.com/DeveloperApp' && resource.name.extract('/apps/{name}').startsWith('bu1-')) ||
resource.type == "cloudresourcemanager.googleapis.com/Project"
Select “CONDITION EDITOR” and paste the condition from above, adjusting “bu1-” to be your resource prefix.
Repeat for the Apigee Developer Admin role.
The final role assignment for the user:
Access for users to specific environments is done in Apigee UI or via APIs on the environment. Access to environments is required to allow management of environment specific resources such as Target Servers, KVMs and PropertySets, since these are not named resources and cannot be used in conditional role assignments. Access to environments is also required to manage deployments for the specific environment.
Role assignment in the Apigee Management UI
GCP IAM and Roles
Apigee Users and Roles
Thanks for writing this up. This helps to start addressing the lack of built-in access control in Apigee, which has been a pain point for us. I followed your steps to test it on my end and wanted to share some feedback when I logged into our org as a test user with the assigned conditional roles:
Otherwise, I think the solution here is a great temporary workaround until a more native solution is released in Apigee.
I agree, it's not 100% and there are some UI "subtleties".
Good point regarding Apps, I just wanted to show what I learned about "resource.name.extract".
BTW, there's another article showing this using groups.
Hello @kurtkanaskie, thanks for your article, this was very helpful in managing users at an organisational level.
At environmental level I already assigned custom roles to groups of users . Do you know if by using API calls or apigeecli commands we will also be able to restrict access to specific KVMs or target servers?
I would like to apply conditions also for environmental resources.
Hi @sebastiank,
KVMs, target servers and other environment specific resources are not "named" resources and cannot use conditional role assignment. Best you can do is to assign "Access" for a user or group to the environment.
Hi @kurtkanaskie,
I have applied the condition for ApiProducts and Developers. But all the products are accessible on UI. The condition on IAM doesn't seen to work. Please let me know what can cause this issue.
Hi @nswapna,
I just re-tested this and it works on my organization. I have 2 products "bu1-product-1" and "bu2-product-1". A user that is assigned conditions for "resource.name.startsWith(\"organizations/apigeex-exp/apiproducts/bu1-\")" is only able to access a product that begins with "bu1-". They can see all the products in the list, but cannot access anything besides "bu1-" prefixed products.
Make sure you have only assigned roles "Apigee API Admin" and "Apigee Developer Admin" with conditions, along with the "Custom Role Apigee X Deploy and Debug" without conditions in GCP IAM.
Can i create an IAM condition to control access to Developer portal ?
Say, i want user 'A' to be allowed to created pages/menu only with artifact starting with 'A'
similarly, user 'B' to be allowed to created pages/menu only with artifact starting with 'B'
IAM conditions are not supported for the Integrated Portal.
See docs:
Hi @kurtkanaskie,
Thank you for taking the time to write this guide (and the groups one).
I reproduced this configuration and encountered some issues. In the end, our users were redirected to the APIGee home UI, regardless of how we configured the conditions.
A short while ago, I was checking this with GCP support, and they asked me to add these permissions to custom role:
- apigee.entitlements.get
- apigee.projectorganizations.get
- apigee.setupcontexts.get
After this, it worked.
These permissions are listed here I think I overlooked them.
This could be helpful for others as well.
Thanks @alnino
I had 2 of those permissions in the article using Groups: RBAC with Fine Grained Access - Apigee X - Using Groups
- apigee.entitlements.get
- apigee.projectorganizations.get
I've updated both articles.
Thanks!
Hello @kurtkanaskie ,
Thank you for this article. I have tried using this method to fine grain access to specific users but have some questions:
My Goal is to restrict proxy view (list) access for a principal for them to only see the proxies which starts with "TEAM2" in the ApigeeX UI.
I followed the article and created two custom roles, one with conditions and another one without for the principal:
1. Role 1 (No Conditions):
2. Role 2 - With Condition
Condition: