Configure Extended Session Length for Workforce Identity Federation

By default, Workforce Identity Federation sessions have a maximum duration of 12 hours. With extended session length, you can configure sessions that last up to 90 days for the following:

  • OAuth apps owned by Google Cloud projects: Configured using project scopes (restricted_project). Workforce users can maintain an uninterrupted connection to OAuth apps owned by the specified project without daily reauthentication against your external identity provider (IdP).

  • Supported Google Cloud applications: Configured using application scopes (restricted_client_application). Workforce users can maintain an uninterrupted connection to supported applications, such as the Gemini Enterprise mobile and desktop apps, without daily reauthentication against your external IdP.

To maintain security throughout extended sessions, Google Cloud periodically synchronizes user attributes and group memberships directly from your external identity provider (IdP) in the background.

This document describes how to define extended session policies using the Access Context Manager API with project-scoped and application-scoped controls, configure your workforce pool provider, and manage active bindings.


How extended session length works

Workforce Identity Federation uses Access Context Manager Google Cloud access bindings to configure extended session length:

  • Google Cloud access binding: Administrators define a session length policy using Access Context Manager that applies organization-wide across all workforce pools in your organization. Policies grant extended sessions of up to 90 days using either one of the following:

    • Project scope (restricted_project): Applies extended sessions to OAuth apps owned by the designated Google Cloud project.

    • Application scope (restricted_client_application): Applies extended sessions to supported Google Cloud applications.

  • Background attribute synchronization:

    • OIDC: Supported using either an OIDC Authorization Code flow with the offline_access scope (using refresh tokens to periodically refresh user attributes and group memberships from your external IdP in the background) or through SCIM provisioning.

    • SAML: For SAML providers, user attributes and group memberships are kept up-to-date using SCIM provisioning.

  • Staleness protection: If user attributes cannot be refreshed from the external IdP within 24 hours (for example, if the user is deprovisioned or credentials are revoked at the IdP), Google Cloud terminates the session.

  • Session revocation: To sign a user out immediately, before their extended session expires, revoke the user's sessions.


Before you begin

Before configuring extended session length, ensure you have the required Identity and Access Management permissions and APIs enabled:

Required roles and permissions

To get the permissions that you need to configure extended session length, ask your administrator to grant you the following IAM roles:

Enable APIs

Enable the Access Context Manager and IAM APIs in your project:

gcloud services enable \
    accesscontextmanager.googleapis.com \
    iam.googleapis.com

Supported applications

Application scopes (restricted_client_application) support only the following Google Cloud applications. To scope a policy to an application, set the name field to the exact, case-sensitive application name:

Application Application name
Gemini Enterprise mobile app (Android) Gemini Enterprise mobile Android
Gemini Enterprise mobile app (iOS) Gemini Enterprise mobile IOS
Gemini Enterprise desktop app Gemini Enterprise Desktop

Identifying applications by OAuth client ID (clientId) isn't supported.


Limitations and Requirements

Before configuring extended session length, review the following requirements and limitations:

  • Supported scopes: Session settings must be configured within scopedAccessSettings using one of the following client scopes:
    • restricted_project scope: Applies to OAuth apps owned by a Google Cloud project. Specify the project by its project number (projects/{PROJECT_NUMBER}).
    • restricted_client_application scope: Applies to supported Google Cloud applications. Specify the application by its application name (the name field).
    • You must use one of the exact application names listed in Supported applications.
    • Scoping by OAuth client ID (clientId) is not supported for Workforce Identity Federation bindings and will be rejected. You must identify the application using the name field.
  • Session duration range: Session duration must be between a minimum of 1 hour (3600s) and a maximum of 90 days (7776000s).
  • Session settings parameter requirements:
    • session_length_enabled: Must be set to true.
    • session_length: Required duration between 1 hour (3600s) and 90 days (7776000s).
    • session_reauth_method: Must be unset or set to LOGIN.
    • use_oidc_max_age: Must be unset or set to false.
    • max_inactivity: Must be unset (or default 0s). Idle session timeouts are not supported for restricted_project bindings and restricted_client_application bindings.
  • Supported identity providers:
    • OIDC with the authorization code flow: Requires the offline_access scope so that your IdP issues refresh tokens, or SCIM provisioning for users and groups with --scim-usage=enabled-for-users-groups set on the workforce identity pool provider.
    • OIDC with the implicit flow and SAML 2.0: Requires SCIM provisioning for users and groups, and --scim-usage=enabled-for-users-groups set on the workforce identity pool provider. Extended session length isn't supported with --scim-usage=enabled-for-groups.
  • Attribute staleness threshold: A fixed 24-hour staleness threshold is enforced. If Google Cloud cannot refresh user attributes from your IdP within 24 hours, the session is invalidated and the user must reauthenticate.
  • Access Context Manager constraints:
    • Single organizational binding: Extended session length bindings for workforce pools must target the organization's "all workforce pools" principal (principalSet://cloudresourcemanager.googleapis.com/organizations/{ORG_ID}/type/WorkforcePool). Because this federated principal identifier applies organization-wide across all workforce pools in your organization, only one such binding can exist per organization. To configure extended sessions for multiple projects, applications, or a combination of both, include multiple restricted_project and restricted_client_application scope blocks within the binding's single scopedAccessSettings list.
    • Access levels (access_levels, dry_run_access_levels) are not supported on workforce pool bindings.
    • Top-level sessionSettings directly on the GcpUserAccessBinding are not supported for workforce pool bindings; settings must be defined within scopedAccessSettings.activeSettings.sessionSettings.

Configure the workforce pool provider

To allow extended session length, your workforce pool provider must be configured to support background attribute refresh. You can configure the provider to use either the OIDC or SAML protocol.

Configure an OIDC provider

If your OIDC provider uses the implicit flow (--web-sso-response-type=id-token), token-based attribute refresh isn't available. Configure SCIM instead, or switch the provider to the authorization code flow.

Background attribute refresh for OIDC providers can be handled using either refresh tokens (offline_access scope) or SCIM provisioning. If using token-based attribute refresh:

  1. In your external IdP, configure an OIDC application with Authorization Code Flow and enable Offline Access so that a refresh token is returned.
  2. In Google Cloud, add offline_access to the additional scopes on your OIDC workforce pool provider.

Offline access must be configured on all workforce identity pools in your Google Cloud organization for the extended session length policy to have the intended effect.

gcloud

If your provider already has existing additional scopes, include them alongside offline_access so they are not overwritten:

gcloud iam workforce-pools providers update-oidc PROVIDER_ID \
    --workforce-pool=WORKFORCE_POOL_NAME \
    --location=global \
    --web-sso-additional-scopes="offline_access[,EXISTING_ADDITIONAL_SCOPES]"

Replace the following:

  • PROVIDER_ID: The name of your workforce identity pool provider.
  • WORKFORCE_POOL_NAME: The name of your workforce identity pool.
  • EXISTING_ADDITIONAL_SCOPES: Any comma-separated additional scopes previously configured on the provider. If you have no existing additional scopes, omit this parameter.

REST API

Send a PATCH request to update the provider. Include any existing additional scopes alongside offline_access:

PATCH https://iam.googleapis.com/v1/locations/global/workforcePools/WORKFORCE_POOL_NAME/providers/PROVIDER_ID?updateMask=oidc.webSsoConfig.additionalScopes

Request body:

{
  "oidc": {
    "webSsoConfig": {
      "additionalScopes": [
        "offline_access"
      ]
    }
  }
}

Replace the following:

  • WORKFORCE_POOL_NAME: The name of your workforce identity pool.
  • PROVIDER_ID: The ID of your workforce identity pool provider.

Configure SCIM for SAML and OIDC implicit flow providers

For SAML providers, and for OIDC providers that use the implicit flow, background attribute refresh requires SCIM provisioning:

  1. Set up a SCIM tenant for your workforce pool provider.
  2. Configure user and group provisioning from your identity provider to the SCIM endpoint.
  3. After all users and groups are synced to Google Cloud, set --scim-usage=enabled-for-users-groups on your workforce identity pool provider. Extended session length isn't supported with --scim-usage=enabled-for-groups.

For step-by-step instructions, see SCIM provisioning for Workforce Identity Federation and "Enable SCIM for users and groups" for Microsoft Entra ID or Okta.


Example policy configuration for Google Cloud projects

Create a GcpUserAccessBinding resource that assigns the extended session length policy to your organization's workforce pools, scoping the policy to OAuth apps owned by a Google Cloud project.

gcloud

Define the policy in a YAML file named esl-binding.yaml:

scopedAccessSettings:
- scope:
    clientScope:
      restrictedProject:
        name: projects/PROJECT_NUMBER
  activeSettings:
    sessionSettings:
      sessionLength: 7776000s
      sessionLengthEnabled: true
      sessionReauthMethod: LOGIN

Create the access binding:

gcloud access-context-manager cloud-bindings create \
    --organization=ORG_ID \
    --federated-principal="principalSet://cloudresourcemanager.googleapis.com/organizations/ORG_ID/type/WorkforcePool" \
    --binding-file="esl-binding.yaml"

Replace the following:

  • ORG_ID: Your Google Cloud organization ID (for example, 123456789012).
  • PROJECT_NUMBER: The Google Cloud project number to apply extended session length to (for example, 987654321098). All OAuth apps owned by this project receive the extended session length.
  • sessionLength: The session duration in seconds followed by s. For example, 7776000s specifies a 90-day session.
  • sessionLengthEnabled: Set to true.
  • sessionReauthMethod: Set to LOGIN (or leave unset).

REST API

Send a POST request to the Access Context Manager API:

POST https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings

JSON request body:

{
  "principal": {
    "federatedPrincipal": "principalSet://cloudresourcemanager.googleapis.com/organizations/ORG_ID/type/WorkforcePool"
  },
  "scopedAccessSettings": [
    {
      "scope": {
        "clientScope": {
          "restrictedProject": {
            "name": "projects/PROJECT_NUMBER"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
          "sessionLength": "7776000s",
          "sessionLengthEnabled": true,
          "sessionReauthMethod": "LOGIN"
        }
      }
    }
  ]
}

Replace the following:

  • ORG_ID: Your Google Cloud organization ID (for example, 123456789012).
  • PROJECT_NUMBER: The Google Cloud project number to apply extended session length to (for example, 987654321098). All OAuth apps owned by this project receive the extended session length.
  • sessionLength: The session duration in seconds followed by s. For example, 7776000s specifies a 90-day session.
  • sessionLengthEnabled: Set to true.
  • sessionReauthMethod: Set to LOGIN (or leave unset).

Example policy configuration for Google Cloud applications

Create a GcpUserAccessBinding resource that assigns the extended session length policy to your organization's workforce pools, scoping the policy to supported Google Cloud applications using the restricted_client_application scope. This example uses the application names for the Gemini Enterprise mobile apps. For the full list of supported applications, see Supported applications.

gcloud

Define the policy in a YAML file named esl-app-binding.yaml:

scopedAccessSettings:
- scope:
    clientScope:
      restrictedClientApplication:
        name: "Gemini Enterprise mobile Android"
  activeSettings:
    sessionSettings:
      sessionLength: 7776000s
      sessionLengthEnabled: true
      sessionReauthMethod: LOGIN
- scope:
    clientScope:
      restrictedClientApplication:
        name: "Gemini Enterprise mobile IOS"
  activeSettings:
    sessionSettings:
      sessionLength: 7776000s
      sessionLengthEnabled: true
      sessionReauthMethod: LOGIN

Create the access binding:

gcloud access-context-manager cloud-bindings create \
    --organization=ORG_ID \
    --federated-principal="principalSet://cloudresourcemanager.googleapis.com/organizations/ORG_ID/type/WorkforcePool" \
    --binding-file="esl-app-binding.yaml"

Replace the following:

  • ORG_ID: Your Google Cloud organization ID (for example, 123456789012).
  • name: The exact name of a supported application. Identifying applications by OAuth client ID (clientId) is not supported.
  • sessionLength: The session duration in seconds followed by s (between 3600s and 7776000s).
  • sessionLengthEnabled: Set to true.
  • sessionReauthMethod: Set to LOGIN (or leave unset).

REST API

Send a POST request to the Access Context Manager API:

POST https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings

JSON request body:

{
  "principal": {
    "federatedPrincipal": "principalSet://cloudresourcemanager.googleapis.com/organizations/ORG_ID/type/WorkforcePool"
  },
  "scopedAccessSettings": [
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "name": "Gemini Enterprise mobile Android"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
          "sessionLength": "7776000s",
          "sessionLengthEnabled": true,
          "sessionReauthMethod": "LOGIN"
        }
      }
    },
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "name": "Gemini Enterprise mobile IOS"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
          "sessionLength": "7776000s",
          "sessionLengthEnabled": true,
          "sessionReauthMethod": "LOGIN"
        }
      }
    }
  ]
}

Replace the following:

  • ORG_ID: Your Google Cloud organization ID (for example, 123456789012).
  • name: The exact name of a supported application. Identifying applications by OAuth client ID (clientId) is not supported.
  • sessionLength: The session duration in seconds followed by s. For example, 7776000s specifies a 90-day session.
  • sessionLengthEnabled: Set to true.
  • sessionReauthMethod: Set to LOGIN (or leave unset).

Viewing and listing bindings

Because the binding applies across all workforce pools in the organization, there is at most one access binding per organization.

List active bindings

To list the workforce pool access binding in your organization, use the principal:federatedPrincipal filter:

gcloud

gcloud access-context-manager cloud-bindings list \
    --organization=ORG_ID \
    --filter="principal:federatedPrincipal"

REST API

GET https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings?filter=principal:federated_principal

Get binding details

To view the details of a specific workforce pool access binding:

gcloud

gcloud access-context-manager cloud-bindings describe \
    --binding=BINDING_NAME

Replace BINDING_NAME with the full resource name of the binding (for example, organizations/123456789012/gcpUserAccessBindings/b1234567890).

REST API

GET https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings/BINDING_ID

Replace the following:

  • ORG_ID: Your Google Cloud organization ID (for example, 123456789012).
  • BINDING_ID: The ID of your access binding (for example, b1234567890).

Update an access binding

You can update an existing workforce pool access binding to modify session lengths, add new project or application scopes, or remove existing scopes.

gcloud

  1. Define the updated policy in a YAML file named updated-esl-binding.yaml:

    scopedAccessSettings:
    - scope:
        clientScope:
          restrictedProject:
            name: projects/PROJECT_NUMBER
      activeSettings:
        sessionSettings:
          sessionLength: 2592000s
          sessionLengthEnabled: true
          sessionReauthMethod: LOGIN
    
  2. Apply the updated policy:

    • Replace scoped access settings: To overwrite the existing scopes with the configuration defined in updated-esl-binding.yaml:
    gcloud access-context-manager cloud-bindings update \
        --binding=BINDING_NAME \
        --binding-file="updated-esl-binding.yaml"
    
    • Append to existing settings: To append the scopes defined in updated-esl-binding.yaml to the binding's existing scopes without overwriting them, pass the --append flag:
    gcloud access-context-manager cloud-bindings update \
        --binding=BINDING_NAME \
        --binding-file="updated-esl-binding.yaml" \
        --append
    

Replace the following: * BINDING_NAME: The full resource name of the binding (for example, organizations/123456789012/gcpUserAccessBindings/b1234567890). * PROJECT_NUMBER: The Google Cloud project number to apply extended session length to. All OAuth apps owned by this project receive the extended session length. * sessionLength: The updated session duration (for example, 2592000s for 30 days).

REST API

Send a PATCH request to update the binding.

  • Replace scoped access settings: To overwrite existing scopes:
PATCH https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings/BINDING_ID?updateMask=scopedAccessSettings
  • Append to existing settings: To append new scopes without overwriting existing ones, set the append=true query parameter:
PATCH https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings/BINDING_ID?updateMask=scopedAccessSettings&append=true

JSON request body:

{
"scopedAccessSettings": [
  {
    "scope": {
      "clientScope": {
        "restrictedProject": {
          "name": "projects/PROJECT_NUMBER"
        }
      }
    },
    "activeSettings": {
      "sessionSettings": {
        "sessionLength": "2592000s",
        "sessionLengthEnabled": true,
        "sessionReauthMethod": "LOGIN"
      }
    }
  }
]
}

Replace the following: * ORG_ID: Your Google Cloud organization ID (for example, 123456789012). * BINDING_ID: The ID of your access binding (for example, b1234567890). * PROJECT_NUMBER: The Google Cloud project number to apply extended session length to. All OAuth apps owned by this project receive the extended session length. * sessionLength: The updated session duration (for example, 2592000s for 30 days).


Delete an access binding

If you delete the workforce pool access binding, extended session length is disabled for all workforce pools in your organization.

gcloud

gcloud access-context-manager cloud-bindings delete \
    --binding=BINDING_NAME

Replace BINDING_NAME with the full resource name of the binding.

REST API

Send a DELETE request to remove the binding:

DELETE https://accesscontextmanager.googleapis.com/v1/organizations/ORG_ID/gcpUserAccessBindings/BINDING_ID

Replace the following:

  • ORG_ID: Your Google Cloud organization ID.
  • BINDING_ID: The ID of the access binding to delete.

What's next