Configure session controls for reauthentication

Session controls let you configure how often users must reauthenticate after being granted access and whether a full login, password only, or hardware security key is required.

You can apply session controls to do the following:

  • Enforce frequent reauthentication for privileged users: Require users with elevated privileges, such as project owners and billing administrators, to reauthenticate more frequently.
  • Configure longer sessions for certain applications: Allow supported applications, such as the Google Cloud console, Google Cloud SDK, or specific OAuth apps, to have longer session durations to preserve the large context window required for optimal performance.

Define session length and reauthentication methods

You can define session controls when creating an Access Context Manager binding. For more information about session controls, see Apply policies to user groups using access bindings.

gcloud

  • Set default session controls for all applications

    Use the --session-length flag to set the session duration. For Google Cloud user sessions, the duration must be 0s (or 0h), or between 1 hour and 24 hours. The maximum session length for Google Cloud user sessions is 24 hours. Specify the duration in hours. For example, use 12h to set a session that is 12 hours long. To increase the session length beyond the default 16 hours, set --session-length up to 24h, or set --session-length=0 to disable session length limits. For Workforce Identity Federation extended sessions, the maximum duration is 90 days. Use the --session-reauth-method flag to specify the reauthentication method. For example, you can set a session duration of 3 hours (3h) and a LOGIN, PASSWORD, or SECURITY_KEY reauthentication method.

    This will be applied to all applications unless overridden by application-specific settings.

  • Set application-specific session controls

    Define scopedAccessSettings in a YAML file to specify session controls for specific applications using clientId. This lets you override the default session controls for those applications. You can then pass the YAML file using the --binding-file flag.

REST API

Define the sessionLength and sessionReauthMethod fields within the sessionSettings object in the JSON body of your POST request to create or update a GcpUserAccessBinding binding.

  • sessionLength is the session duration in seconds, formatted as the number of seconds followed by s (for example, 3600s). For Google Cloud user sessions, the value must be 0s or from 3600s (1 hour) to 86400s (24 hours). The maximum session length for Google Cloud user sessions is 24 hours (86400s). To increase session length beyond the default 16 hours, set sessionLength up to 86400s (24 hours), or set sessionLength to 0s and sessionLengthEnabled to false to disable session limits (infinite session length). If set to 0s, then sessionLengthEnabled must be set to false or left unset. You cannot set sessionLength to 0s and sessionLengthEnabled to true. For Workforce Identity Federation, extended sessions allow up to 90 days (7776000s).
  • sessionReauthMethod can be LOGIN, PASSWORD, or SECURITY_KEY.
  • Use scopedAccessSettings to define application-specific session controls. See Define configurations for specific applications for details.

Terraform

Within the Terraform Google Cloud User Access Binding resource, set the session_settings argument to configure general session length controls that apply to all user traffic:

  • session_length: The duration of the session in seconds. For example, 3600s sets the session length to 1 hour, and 86400s sets the maximum session length of 24 hours. The s at the end is required.
  • session_length_enabled: Set to false to disable session limits.
  • session_reauth_method: The type of authentication challenge that is used to refresh credentials. The options are LOGIN, PASSWORD, or SECURITY_KEY.
  • use_oidc_max_age: An advanced field that is used to configure whether the session honors an optional OIDC maximum age parameter, which is specified if the authenticating credential is an OAuth token.

When defining session controls, only the most recently created access binding that matches the request is used when resolving session control settings.

Example policy configuration

The following example shows how to create a session control that requires reauthentication every 18 hours with LOGIN and every two hours for a specific application (SENSITIVE_APP_ID) with SECURITY_KEY.

Default settings

The --level, --session-length, and --session-reauth-method flags in the Google Cloud CLI command (or the corresponding fields in the JSON body for the API call) set the default behavior for all applications not explicitly defined in scopedAccessSettings.

Application-specific settings

The scopedAccessSettings section in the YAML file (or JSON body) lets you override the default settings for specific applications. In the example, we set a two hour reauthentication requirement with SECURITY_KEY for the application with the client ID SENSITIVE_APP_ID.

Application-specific settings in scopedAccessSettings completely override the default (global) session controls. If a scoped setting is defined for an application, the default session controls do not apply to that application.

To exempt certain applications from session control when global controls are active, you must explicitly add them to scopedAccessSettings and set the sessionLength field to 0s and sessionLengthEnabled to false.

gcloud

The following example shows the session settings configuration:

scopedAccessSettings:
- scope:
    clientScope:
      restrictedClientApplication:
        clientId: SENSITIVE_APP_ID
  activeSettings:
    sessionSettings:
      sessionLength: 7200s
      sessionReauthMethod: SECURITY_KEY
      sessionLengthEnabled: true

Create the access binding:

gcloud access-context-manager cloud-bindings create \
    --organization=ORG_ID \
    --group-key=GROUP_ID \
    --binding-file=BINDING_FILE_PATH \
    --session-length=SESSION_LENGTH \
    --session-reauth-method LOGIN

Replace the following:

  • ORG_ID: the ID of the Google Cloud organization

  • GROUP_ID: the unique Cloud Identity group ID

  • BINDING_FILE_PATH: the path of the binding file

  • SESSION_LENGTH: the session length—for example, 18h

To obtain the unique group ID, run the following command:

gcloud identity groups describe GROUP_EMAIL

Replace GROUP_EMAIL with your group's email address. The unique group ID is the value returned after groups/ in the name field in the output. For example, the unique group ID in groups/01gf8i8311xalqg is 01gf8i8311xalqg.

REST API

An example JSON body of the API request:

{
  "groupKey": "GROUP_ID",
  "sessionSettings": {
    "sessionLength": "64800s",
    "sessionReauthMethod": "LOGIN",
    "sessionLengthEnabled": true
  },
  "scopedAccessSettings": [
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "clientId": "SENSITIVE_APP_ID"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
          "sessionLength": "7200s",
          "sessionReauthMethod": "SECURITY_KEY",
          "sessionLengthEnabled": true
        }
      }
    }
  ]
}

Construct the POST request in the following format:

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

Replace ORG_ID with the ID of the Google Cloud organization.

Terraform

To specify session controls that apply globally and to specific applications, set the session_settings and scoped_access_settings arguments:

    resource "google_access_context_manager_gcp_user_access_binding" "gcp_user_access_binding" {
      organization_id = "ORG_ID"
      group_key = "GROUP_ID"
      session_settings {
        session_length = "64800s"
        session_length_enabled = true
        session_reauth_method = "LOGIN"
        use_oidc_max_age = false
      }
      scoped_access_settings {
        scope {
          client_scope {
            restricted_client_application {
              client_id = "CLIENT_ID"
            }
          }
        }
        active_settings {
          session_settings {
            session_length = "7200s"
            session_length_enabled = true
            session_reauth_method = "SECURITY_KEY"
            use_oidc_max_age = false
          }
        }
      }
    }

Replace the following:

  • ORG_ID: the numeric ID of the Google Cloud organization.

  • GROUP_ID: the raw Cloud Identity or Google Workspace Directory API group ID. Don't use a group email address or a "groups/..." resource name. Instead, pass the raw ID or use trimprefix(google_cloud_identity_group.example.id, "groups/").

  • CLIENT_ID: the OAuth 2.0 client ID of the application.

Example policy configuration for Google Cloud applications

You can configure application-specific reauthentication controls for Google Cloud applications, for example requiring SECURITY_KEY for Google Cloud SDK and LOGIN for the Google Cloud console. The following example shows how to create a session control that requires reauthentication every hour for Google Cloud SDK with SECURITY_KEY, and every 4 hours for the Google Cloud console with LOGIN.

The scopedAccessSettings section in the YAML file (or JSON body) lets you override the default settings for specific applications. In this example, we set a one hour reauthentication requirement with SECURITY_KEY for Google Cloud SDK, and a four hour reauthentication requirement with LOGIN for the Google Cloud console using the name field to identify these applications.

To exempt certain applications from session control, set the sessionLength field to 0s or sessionLengthEnabled to false. The sessionReauthMethod method will then be ignored.

gcloud

The following example shows the session settings configuration:

scopedAccessSettings:
- scope:
    clientScope:
      restrictedClientApplication:
        name: Google Cloud SDK
  activeSettings:
    sessionSettings:
      sessionLength: 3600s
      sessionReauthMethod: SECURITY_KEY
      sessionLengthEnabled: true
- scope:
    clientScope:
      restrictedClientApplication:
        name: Cloud Console
  activeSettings:
    sessionSettings:
      sessionLength: 14400s
      sessionReauthMethod: LOGIN
      sessionLengthEnabled: true

Create the access binding:

gcloud access-context-manager cloud-bindings create \
    --organization=ORG_ID \
    --group-key=GROUP_ID \
    --binding-file=BINDING_FILE_PATH

Replace the following:

  • ORG_ID: the ID of the Google Cloud organization

  • GROUP_ID: the unique Cloud Identity group ID

  • BINDING_FILE_PATH: the path of the binding file

REST API

An example JSON body of the API request:

{
  "groupKey": "GROUP_ID",
  "scopedAccessSettings": [
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "name": "Google Cloud SDK"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
            "sessionLength": "3600s",
            "sessionReauthMethod": "SECURITY_KEY",
            "sessionLengthEnabled": true
          }
      }
    },
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "name": "Cloud Console"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
            "sessionLength": "14400s",
            "sessionReauthMethod": "LOGIN",
            "sessionLengthEnabled": true
          }
      }
    }
  ]
}

Construct the POST request in the following format:

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

Replace ORG_ID with the ID of the Google Cloud organization.

Terraform

To specify session length settings for Google Cloud SDK and the Google Cloud console, set the appropriate scoped_access_settings argument:

    resource "google_access_context_manager_gcp_user_access_binding" "gcp_user_access_binding" {
      organization_id = "ORG_ID"
      group_key = "GROUP_ID"
      scoped_access_settings {
        scope {
          client_scope {
            restricted_client_application {
              name = "Google Cloud SDK"
            }
          }
        }
        active_settings {
          session_settings {
            session_length = "3600s"
            session_length_enabled = true
            session_reauth_method = "SECURITY_KEY"
            use_oidc_max_age = false
          }
        }
      }
      scoped_access_settings {
        scope {
          client_scope {
            restricted_client_application {
              name = "Cloud Console"
            }
          }
        }
        active_settings {
          session_settings {
            session_length = "14400s"
            session_length_enabled = true
            session_reauth_method = "LOGIN"
            use_oidc_max_age = false
          }
        }
      }
    }

Replace the following:

  • ORG_ID: the numeric ID of the Google Cloud organization.

  • GROUP_ID: the raw Cloud Identity or Google Workspace Directory API group ID. Don't use a group email address or a "groups/..." resource name. Instead, pass the raw ID or use trimprefix(google_cloud_identity_group.example.id, "groups/").

Override the default 16-hour session length for

Google Cloud applications

Starting in June 2026, a default session length of 16 hours was introduced for a subset of Google Cloud organizations. This default policy isn't visible in the Google Admin console and affected Google Cloud organizations must use the Access Context Manager API to override it for their users.

To override this default policy, you can increase the session length up to the maximum of 24 hours (86400s), or exempt these applications from session control (making the session length effectively infinite) by creating a cloud binding with scopedAccessSettings where sessionLengthEnabled is set to false for both the Google Cloud SDK and Google Cloud console ("Cloud Console") applications.

gcloud

The following example shows the YAML configuration to disable session controls for these applications:

scopedAccessSettings:
- scope:
    clientScope:
      restrictedClientApplication:
        name: Google Cloud SDK
  activeSettings:
    sessionSettings:
      sessionLength: 0s
      sessionReauthMethod: LOGIN
      sessionLengthEnabled: false
- scope:
    clientScope:
      restrictedClientApplication:
        name: Cloud Console
  activeSettings:
    sessionSettings:
      sessionLength: 0s
      sessionReauthMethod: LOGIN
      sessionLengthEnabled: false

Create or update the access binding using this file:

gcloud access-context-manager cloud-bindings create \
    --organization=ORG_ID \
    --group-key=GROUP_ID \
    --binding-file=BINDING_FILE_PATH

Replace the following:

  • ORG_ID: the ID of the Google Cloud organization

  • GROUP_ID: the unique Cloud Identity group ID (for example, the ID of a group that contains all the users that you want this override to apply to)

  • BINDING_FILE_PATH: the path of the binding file

REST API

An example JSON body of the API request:

{
  "groupKey": "GROUP_ID",
  "scopedAccessSettings": [
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "name": "Google Cloud SDK"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
          "sessionLength": "0s",
          "sessionReauthMethod": "LOGIN",
          "sessionLengthEnabled": false
        }
      }
    },
    {
      "scope": {
        "clientScope": {
          "restrictedClientApplication": {
            "name": "Cloud Console"
          }
        }
      },
      "activeSettings": {
        "sessionSettings": {
          "sessionLength": "0s",
          "sessionReauthMethod": "LOGIN",
          "sessionLengthEnabled": false
        }
      }
    }
  ]
}

Construct the POST request in the following format:

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

Replace ORG_ID with the ID of the Google Cloud organization.

Terraform

To specify that session controls are disabled for Google Cloud SDK and the Google Cloud console, set the appropriate scoped_access_settings argument with session_length_enabled = false:

    resource "google_access_context_manager_gcp_user_access_binding" "gcp_user_access_binding" {
      organization_id = "ORG_ID"
      group_key = "GROUP_ID"
      scoped_access_settings {
        scope {
          client_scope {
            restricted_client_application {
              name = "Google Cloud SDK"
            }
          }
        }
        active_settings {
          session_settings {
            session_length = "0s"
            session_length_enabled = false
            session_reauth_method = "LOGIN"
            use_oidc_max_age = false
          }
        }
      }
      scoped_access_settings {
        scope {
          client_scope {
            restricted_client_application {
              name = "Cloud Console"
            }
          }
        }
        active_settings {
          session_settings {
            session_length = "0s"
            session_length_enabled = false
            session_reauth_method = "LOGIN"
            use_oidc_max_age = false
          }
        }
      }
    }

Replace the following:

  • ORG_ID: the numeric ID of the Google Cloud organization.

  • GROUP_ID: the raw Cloud Identity or Google Workspace Directory API group ID. Don't use a group email address or a "groups/..." resource name. Instead, pass the raw ID or use trimprefix(google_cloud_identity_group.example.id, "groups/").