Grant and revoke access

You can grant and remove role bindings at the organization and project levels or revoke active user sessions across zones in Google Distributed Cloud (GDC) air-gapped. Every subject—a user, group, or service identity—requires an IAMRoleBinding custom resource linked to an IAMRole custom resource to access resources in the global API server and Kubernetes clusters. For conceptual background on additive permissions and global replication, see Authorization and access control.

This document is for audiences within the platform administrator group and application operator group who manage permissions within GDC organizations and projects. For more information, see Audiences for GDC documentation.

Before you begin

Before managing role bindings or revoking access, you must request the necessary permissions and prepare your environment. The specific roles required depend on whether you're managing organization-level role bindings, managing project-level role bindings, or revoking user access.

Request IAM organization roles

Contact your IAM Org Admin to request the following roles:

  • IAM Org Admin (organization-iam-admin): create, update, and delete role bindings at the organization and project levels.
  • Session Org Admin (org-session-admin): revoke a user's active sessions within a specific zone.

Request IAM project roles

Contact your IAM Org Admin or IAM Project Admin to request the following role:

  • IAM Project Admin (project-iam-admin): create, update, and delete role bindings within a specific project. The IAM Org Admin can grant this role for any project within the organization, while the IAM Project Admin can grant this role within the scope of their specific project.

Prepare your environment

To use the command-line tools for managing role bindings or revoking access, complete the following setup:

Find a role's name and namespace

Before you create or delete an IAMRoleBinding resource, look up the target IAMRole resource's name and namespace on the global API server. You need these values when you set up role bindings or remove role bindings.

List organization role details

List the names and namespaces for organization-scoped predefined roles:

kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG \
  get iamroles.iam.global.gdc.goog -A \
  -l 'user-roles.system.private.gdc.goog/type=predefined,user-roles.system.private.gdc.goog/persona=platform-admin' \
  -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,DISPLAY_NAME:.metadata.annotations.user-roles\.system\.private\.gdc\.goog/ui-display-name,PERSONA:.metadata.labels.user-roles\.system\.private\.gdc\.goog/persona,BINDING_TYPE:.metadata.annotations.user-roles\.system\.private\.gdc\.goog/binding-type'

Replace GLOBAL_API_SERVER_KUBECONFIG with the path to the kubeconfig file for the global API server.

The output is similar to the following:

NAMESPACE        NAME                 DISPLAY_NAME                PERSONA          BINDING_TYPE
billing-system   billing-viewer       Billing Viewer              platform-admin   rolebinding
istio-system     web-tls-cert-admin   Web TLS Certificate Admin   platform-admin   rolebinding
platform         project-creator      Project Creator             platform-admin   clusterrolebinding

When you set up role bindings using the API, use the value in the NAMESPACE column for BINDING_NAMESPACE and the value in the NAME column for ROLE_NAME. The other columns are for reference only. Regardless of the BINDING_TYPE value, always create an IAMRoleBinding resource.

List project role details

Project-scoped predefined roles always reside in the target project's namespace. To find a role's name, list the predefined roles in a project:

kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG \
  get iamroles.iam.global.gdc.goog -n PROJECT_NAMESPACE \
  -l 'user-roles.system.private.gdc.goog/type=predefined,user-roles.system.private.gdc.goog/persona=app-operator' \
  -o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,DISPLAY_NAME:.metadata.annotations.user-roles\.system\.private\.gdc\.goog/ui-display-name,PERSONA:.metadata.labels.user-roles\.system\.private\.gdc\.goog/persona,BINDING_TYPE:.metadata.annotations.user-roles\.system\.private\.gdc\.goog/binding-type'

Replace the following:

  • GLOBAL_API_SERVER_KUBECONFIG: the path to the kubeconfig file for the global API server.
  • PROJECT_NAMESPACE: the namespace of the target project.

The output is similar to the following:

NAMESPACE    NAME              DISPLAY_NAME      PERSONA        BINDING_TYPE
my-project   namespace-admin   Namespace Admin   app-operator   projectrolebinding
my-project   project-viewer    Project Viewer    app-operator   rolebinding

When you set up role bindings using the API, use the value in the NAME column for ROLE_NAME and your project's namespace (PROJECT_NAMESPACE) for BINDING_NAMESPACE. The other columns are for reference only. Regardless of the BINDING_TYPE value, always create an IAMRoleBinding resource.

Set up role bindings

You can set up role bindings that give team members access to resources at the organization or project level.

Assign a role to an authorized member:

Console

  1. Sign in to the GDC console.
  2. From the scope picker in the menu bar, select an organization or project and click Open.
  3. In the navigation menu, click Identity & Access > Access.
  4. Click Add Member.
  5. In the Member type section, select User to add individual users or Group to add groups.
  6. In the Identity provider list, select an identity provider.
  7. In the Username or group alias field, enter the username, email address, or alias.
  8. In the Roles section, select the role that you want to grant to the user or group from the Role 1 list, such as IAM Org Viewer at the organization level or Project Viewer at the project level. To grant multiple roles at a time to the selected user or group, click Add Another Role.
  9. Click Add.

The member appears in the Authorized members list on the Access page.

gdcloud

  1. Ensure you have the gdcloud CLI installed.

  2. Sign in using the gdcloud auth login command to authenticate with your identity provider. For more information, see gdcloud CLI authentication.

  3. Set up role bindings for your target scope:

    • Organization-level:

      gdcloud organizations add-iam-policy-binding ORGANIZATION \
        --member=USER_ACCOUNT \
        --role=ROLE
      
    • Project-level:

      gdcloud projects add-iam-policy-binding PROJECT \
        --member=USER_ACCOUNT \
        --role=ROLE
      

    Replace the following variables:

    • ORGANIZATION or PROJECT: the name of the organization or project for which you're setting up the role binding.
    • USER_ACCOUNT: the user account to which you want to grant the role. This flag accepts a user email address with the identity provider prefix (user:idpprefix-user@example.com) or a service account name with the service account project (serviceAccount:projectName:serviceAccountName).
    • ROLE: the name of the predefined or custom role you want to assign to the user.

API

You must create the IAMRoleBinding resource in the same namespace as the target IAMRole resource.

  1. Export the environment variables for the role binding:

    export GLOBAL_API_SERVER_KUBECONFIG=GLOBAL_API_SERVER_KUBECONFIG
    export USERNAME=IDP_PREFIX-USERNAME
    export ROLE_NAME=ROLE_NAME
    export BINDING_NAMESPACE=BINDING_NAMESPACE
    export USER_EMAIL=IDP_PREFIX-USER_EMAIL
    

    Replace the following:

    • GLOBAL_API_SERVER_KUBECONFIG: the path to the kubeconfig file for the global API server.
    • IDP_PREFIX: the identity provider prefix.
    • USERNAME: the username portion of the user's email address before the @ symbol (such as paul from paul@example.com).
    • ROLE_NAME: the name of the IAMRole resource to grant (such as project-creator or project-viewer). See Find a role's name and namespace or Predefined role permissions.
    • BINDING_NAMESPACE: the namespace where the target IAMRole resource resides. Use the target project's namespace for project-scoped roles, or see Find a role's name and namespace for organization-scoped roles.
    • USER_EMAIL: the email address of the user account for which you want to assign the role (such as paul@example.com).
  2. Create and apply an IAMRoleBinding custom resource:

    cat <<EOF | kubectl --kubeconfig ${GLOBAL_API_SERVER_KUBECONFIG} apply -f -
    apiVersion: iam.global.gdc.goog/v1
    kind: IAMRoleBinding
    metadata:
      name: ${USERNAME}-${ROLE_NAME}-binding
      namespace: ${BINDING_NAMESPACE}
    spec:
      roleRef:
        apiGroup: iam.global.gdc.goog
        kind: IAMRole
        name: ${ROLE_NAME}
      subjects:
      - apiGroup: rbac.authorization.k8s.io
        kind: User
        name: ${USER_EMAIL}
    EOF
    

Remove role bindings

When access is no longer required, remove a member and their associated roles, permissions, and access.

To remove members, complete the following steps:

Console

  1. Sign in to the GDC console.
  2. From the scope picker in the menu bar, select an organization or project and click Open.
  3. In the navigation menu, click Identity & Access > Access.
  4. In the Authorized members list, select one or more members.
  5. Click Remove All Access to remove all role bindings associated with the selected members from your current organization or project.
  6. When prompted, enter remove in the Confirm by typing the following below field, and then click Remove to confirm.

gdcloud

  1. Ensure you have the gdcloud CLI installed.

  2. Sign in using the gdcloud auth login command to authenticate with your identity provider. For more information, see gdcloud CLI authentication.

  3. Remove role bindings for your target scope:

    • Organization-level:

      gdcloud organizations remove-iam-policy-binding ORGANIZATION \
        --member=USER_ACCOUNT \
        --role=ROLE
      
    • Project-level:

      gdcloud projects remove-iam-policy-binding PROJECT \
        --member=USER_ACCOUNT \
        --role=ROLE
      

    Replace the following variables:

    • ORGANIZATION or PROJECT: the name of the organization or project from which you're removing the role binding.
    • USER_ACCOUNT: the user account from which you want to remove the role. This flag accepts a user email address with the identity provider prefix (user:idpprefix-user@example.com) or a service account name with the service account project (serviceAccount:projectName:serviceAccountName).
    • ROLE: the name of the predefined or custom role you want to remove from the user account.

kubectl

Delete the IAMRoleBinding to revoke the permission granted to the account:

kubectl --kubeconfig GLOBAL_API_SERVER_KUBECONFIG \
  delete iamrolebinding IDP_PREFIX-USERNAME-ROLE_NAME-binding -n BINDING_NAMESPACE

Replace the following:

  • GLOBAL_API_SERVER_KUBECONFIG: the path to the kubeconfig file for the global API server.
  • IDP_PREFIX: the identity provider prefix.
  • USERNAME: the username portion of the user's email address before the @ symbol (such as paul from paul@example.com).
  • ROLE_NAME: the name of the IAMRole resource to revoke (such as project-creator or project-viewer). See Find a role's name and namespace or Predefined role permissions.
  • BINDING_NAMESPACE: the namespace where the target IAMRole resource resides. Use the target project's namespace for project-scoped roles, or see Find a role's name and namespace for organization-scoped roles.

Revoke user access

If a member leaves your organization or team, a user with the Session Org Admin (org-session-admin) role can revoke their active sessions in Distributed Cloud. Revoking a user's access signs them out of active sessions in the targeted zone, but doesn't delete their IAMRoleBinding custom resources or remove their roles and permissions. To permanently remove the user's roles, follow the steps in Remove role bindings.

To revoke a user's access across a GDC universe, you must revoke access for each individual zone separately. Complete the following steps for each zone:

  1. Make sure you're signed in to the zone you want to revoke access for. For example, set the zonal URL configuration for gdcloud CLI, and then sign in:

    gdcloud config set organization_console_url ZONE_URL
    gdcloud auth login
    

    Replace ZONE_URL with the GDC console URL for the zone to revoke user access for, which resembles https://console.ORG_NAME.ZONE_NAME.ORG_SUFFIX.

    For more information about switching zonal contexts, see Access zones with your tools.

  2. Revoke the user's access for the zone:

    gdcloud admin auth revoke --accounts USER_EMAIL
    

    Replace USER_EMAIL with the email of the user to revoke access.

    After running the command, you see output similar to the following. This example revokes access from the user ariel@example.com:

    Success: NUMBER of sessions revoked for user ariel@example.com
    

    In this example, the variable NUMBER refers to the number of active sessions the user had.

  3. Confirm you've revoked the user's access by running the gdcloud admin auth revoke command again. If successful, you see the following:

    No sessions found for account: ariel@example.com
    
  4. Repeat the previous steps for each zone in your universe.