Google Cloud 会话控制升级:按用户组和应用设置重新认证边界

2026-09-16 22 预计阅读时间: 1 分钟
来源: cloud.google.com AI 摘要 Original link

Disclaimer: This article is an AI-assisted summary. Read it together with the original source when precision matters. The summary may omit context, version differences, or edge cases and is not official documentation.

预计阅读时间:11 分钟

Google Cloud 的会话管理,正在从“给整个组织设置一个时长”变成更精细的访问控制工具。此次更新把会话控制深入整合到 Context-Aware Access(CAA),支持按 Google Groups 和具体应用配置策略,并通过 Terraform、gcloud 和 REST API 管理。

这意味着安全团队可以给高权限用户设置更短的会话,同时避免把同样的限制套到所有开发者和 OAuth 集成上。

16 小时默认值是起点,不是统一答案

Google Cloud 已完成默认会话时长的全球推广:此前没有自行配置会话时长的客户,现在适用 16 小时默认会话时长

这里有两个边界需要注意:

  • 这次默认值推广针对尚未自行配置会话时长的客户,不应理解为覆盖所有已有配置。
  • 会话控制有助于降低凭据窃取和账户接管风险,但不能替代 MFA、最小权限或安全监控。

不同用户的风险并不相同。项目所有者、结算管理员与普通开发者,即使位于同一组织部门,也未必应该使用相同的重新认证周期。

从组织单位转向用户组,再细化到应用

过去,会话时长与组织单位(OU)关联。现在,已正式发布的 Session Controls 策略支持 Google Groups,管理员可以跨组织层级为特定用户群设置策略。

例如,可以这样实践:

用户群 目标应用 会话时长示例 配置意图
高权限用户 Google Cloud Console 2 小时 缩短敏感管理操作的重新认证周期
高权限用户 gcloud 2 小时 对命令行管理操作施加相同边界
普通开发者 Console、gcloud 16 小时 在安全与日常开发效率之间取得平衡
使用特定 OAuth 集成的用户 指定 OAuth 应用 单独评估 避免机械套用交互式管理策略

表中的时长是实践示例,不是产品强制要求。

应用维度同样重要。新策略可以针对 Google Cloud Console、gcloud 和特定 OAuth 应用设置会话控制,而不必一刀切地影响所有需要 Google Cloud API scopes 的应用。

这能减少一种常见问题:为了收紧 Cloud SDK 的使用边界,却意外打断依赖 OAuth 的 BI 或仪表盘集成。不过,“支持单独配置”不等于“集成一定不会受影响”,仍需测试实际认证流程。

可以这样实践:先把策略意图纳入代码审查

此次正式发布的自动化能力包括 Terraform、gcloud CLI 和 REST API。不过,来源摘要没有给出具体资源名、命令参数或 API 请求结构,不能据此编造可直接部署的配置。

一个稳妥的起点,是先把策略意图写成可校验的文件,再根据官方文档映射到实际产品配置。

下面是一个完整、仅依赖 Python 标准库的本地示例。运行前,将示例用户组邮箱替换为组织实际使用的 Google Groups 地址。

注意:这是内部策略草案格式,不是 Google Cloud API schema;脚本不会修改云端配置。

cat > session-policy.json <<'JSON'
{
  "policies": [
    {
      "name": "privileged-interactive",
      "group": "cloud-admins@example.com",
      "applications": ["cloud-console", "gcloud"],
      "session_hours": 2
    },
    {
      "name": "developer-interactive",
      "group": "developers@example.com",
      "applications": ["cloud-console", "gcloud"],
      "session_hours": 16
    }
  ]
}
JSON

cat > validate_session_policy.py <<'PY'
import json
from pathlib import Path

data = json.loads(Path("session-policy.json").read_text())
allowed_apps = {"cloud-console", "gcloud", "oauth-app"}
seen = set()

for policy in data["policies"]:
    name = policy["name"]
    if name in seen:
        raise ValueError(f"Duplicate policy name: {name}")
    seen.add(name)

    if "@" not in policy["group"]:
        raise ValueError(f"{name}: invalid group address")

    hours = policy["session_hours"]
    if type(hours) is not int or hours <= 0:
        raise ValueError(f"{name}: session_hours must be a positive integer")

    apps = policy["applications"]
    if not apps or not set(apps) <= allowed_apps:
        raise ValueError(f"{name}: invalid application targets")

    print(
        f"{name}: group={policy['group']}, "
        f"apps={','.join(apps)}, session={hours}h"
    )

print("Local policy-intent validation passed. No cloud changes were made.")
PY

python3 validate_session_policy.py

这段代码的价值不是替代产品校验,而是让团队在代码审查时看清三个问题:限制谁、限制哪个应用、多久重新认证

正式部署时,再根据文档选择 Terraform、gcloud 或 REST API,并核对允许的时长、目标标识、权限要求及策略冲突处理方式。

上线前,先确认影响面和管理入口

此次更新的发布状态需要区分:

  • 已正式发布:Terraform、gcloud、REST API 支持;Google Groups 定向;应用级控制。
  • 预览阶段:通过 Google Cloud Console 管理会话策略,与 Access Context Manager(ACM)中的访问级别和安全绑定一起管理。客户可以申请使用该入口。

建议从一个小范围高权限用户组开始,而不是立即给全员压缩会话时长。上线前至少检查:

  • 用户是否同时属于多个策略目标组,以及实际的冲突处理规则。
  • Console 和 gcloud 触发重新认证后,日常操作是否能顺利恢复。
  • 特定 OAuth 应用是否受到影响,哪些集成需要独立策略。
  • 无人值守任务使用的身份类型,避免把人类用户会话策略当作工作负载身份治理的替代品。
  • 是否准备好回滚方案、用户通知和支持流程。

真正有用的会话控制,不是把所有人的时长都调到最短,而是让风险最高的访问路径拥有更紧的重新认证边界,同时保留正常开发和业务集成的可用性。


English version

Google Cloud Session Controls: Reauthentication by Group and Application

Google Cloud session management is moving beyond a single organization-wide duration. The latest update integrates session controls more deeply into Context-Aware Access (CAA), adds targeting by Google Groups and application, and supports management through Terraform, gcloud, and REST APIs.

Security teams can now apply tighter reauthentication boundaries to privileged users without automatically imposing the same restrictions on every developer and OAuth integration.

The 16-hour default is a baseline, not a universal answer

Google Cloud has completed the global rollout of a 16-hour default session length for customers who had not already configured their own session durations.

Two distinctions matter:

  • The rollout applies to customers without self-configured durations; it should not be read as replacing every existing configuration.
  • Session controls help mitigate credential theft and account takeover risk, but they do not replace MFA, least privilege, or security monitoring.

Project owners, billing administrators, and general developers may need different reauthentication schedules—even when they belong to the same organizational unit.

Target groups, then narrow the application scope

Session durations were previously associated with organizational units. The generally available Session Controls policy now supports Google Groups, allowing administrators to target users across organizational boundaries.

A practical design might look like this:

User group Application target Example duration Purpose
Privileged users Google Cloud Console 2 hours Tighten reauthentication for sensitive administration
Privileged users gcloud 2 hours Apply a similar boundary to command-line administration
General developers Console and gcloud 16 hours Balance security with everyday development
Users of a specific OAuth integration Selected OAuth application Evaluate separately Avoid copying interactive administration settings blindly

These durations are examples, not mandatory product settings.

Application targeting is equally useful. Policies can cover Google Cloud Console, gcloud, or specific OAuth applications rather than applying blanket restrictions to every application requiring Google Cloud API scopes.

That can reduce the risk of tightening Cloud SDK access while unintentionally disrupting OAuth-based BI or dashboard integrations. Separate targeting, however, is not a guarantee of compatibility: test the actual authentication flow.

Put policy intent through code review before deployment

Terraform, gcloud, and REST API support are generally available. The supplied summary does not include resource names, command flags, or request schemas, so an executable deployment configuration cannot safely be inferred from it.

Instead, start with a local policy-intent file and map it to the documented product configuration later.

The complete Python example above uses only the standard library. Replace the example Google Groups addresses before running it.

Its JSON structure is an internal proposal format, not a Google Cloud API schema. It validates positive integer durations, application labels, and unique policy names without modifying cloud resources.

The review questions are deliberately simple:

  1. Who receives the restriction?
  2. Which application does it affect?
  3. How often should reauthentication occur?

For deployment, consult the documentation for supported durations, target identifiers, required permissions, and policy conflict behavior, then implement the configuration using Terraform, gcloud, or the REST API.

Roll out carefully and distinguish release stages

The release status is not uniform:

  • Generally available: Terraform, gcloud, and REST API management; Google Groups targeting; application-specific controls.
  • Preview: managing session policies in Google Cloud Console alongside access levels and security bindings in Access Context Manager (ACM). Customers can sign up to use this entry point.

Begin with a small privileged group rather than shortening sessions for everyone immediately. Before expanding, check:

  • Overlapping group memberships and the documented conflict-resolution rules.
  • Whether Console and gcloud workflows recover cleanly after reauthentication.
  • Whether specific OAuth integrations need separate policies.
  • The identity types used by unattended jobs; human session controls are not a substitute for workload identity governance.
  • Rollback procedures, user communications, and support readiness.

The goal is not the shortest possible session for every user. It is a tighter reauthentication boundary around the highest-risk access paths, while keeping legitimate development and business integrations usable.

English SEO description

Google Cloud session controls add group and app targeting plus Terraform, gcloud, and API support. Learn rollout boundaries and practical policy checks.


相关推荐