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-lengthflag to set the session duration. For Google Cloud user sessions, the duration must be0s(or0h), 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, use12hto set a session that is 12 hours long. To increase the session length beyond the default 16 hours, set--session-lengthup to24h, or set--session-length=0to disable session length limits. For Workforce Identity Federation extended sessions, the maximum duration is 90 days. Use the--session-reauth-methodflag to specify the reauthentication method. For example, you can set a session duration of 3 hours (3h) and aLOGIN,PASSWORD, orSECURITY_KEYreauthentication method.This will be applied to all applications unless overridden by application-specific settings.
Set application-specific session controls
Define
scopedAccessSettingsin a YAML file to specify session controls for specific applications usingclientId. 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.
sessionLengthis the session duration in seconds, formatted as the number of seconds followed bys(for example,3600s). For Google Cloud user sessions, the value must be0sor from3600s(1 hour) to86400s(24 hours). The maximum session length for Google Cloud user sessions is 24 hours (86400s). To increase session length beyond the default 16 hours, setsessionLengthup to86400s(24 hours), or setsessionLengthto0sandsessionLengthEnabledtofalseto disable session limits (infinite session length). If set to0s, thensessionLengthEnabledmust be set tofalseor left unset. You cannot setsessionLengthto0sandsessionLengthEnabledtotrue. For Workforce Identity Federation, extended sessions allow up to 90 days (7776000s).sessionReauthMethodcan beLOGIN,PASSWORD, orSECURITY_KEY.- Use
scopedAccessSettingsto 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,3600ssets the session length to 1 hour, and86400ssets the maximum session length of 24 hours. Thesat the end is required.session_length_enabled: Set tofalseto disable session limits.session_reauth_method: The type of authentication challenge that is used to refresh credentials. The options areLOGIN,PASSWORD, orSECURITY_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 organizationGROUP_ID: the unique Cloud Identity group IDBINDING_FILE_PATH: the path of the binding fileSESSION_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 usetrimprefix(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 organizationGROUP_ID: the unique Cloud Identity group IDBINDING_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 usetrimprefix(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 organizationGROUP_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 usetrimprefix(google_cloud_identity_group.example.id, "groups/").