Professional Cloud Security Engineer
Workforce Identity Federation enables external users, such as employees, contractors, and partners, to access Google Cloud resources using their existing corporate credentials. Instead of synchronizing or creating individual Google accounts, Google Cloud establishes a trust relationship directly with an external identity provider (IdP) like Okta or Microsoft Active Directory. Authentication decisions happen entirely within the external IdP, allowing users to sign in seamlessly via single sign-on (SSO). This model enforces the principle of least privilege by evaluating identity assertions dynamically at login time rather than managing static credentials.
Administrators begin by creating a workforce identity pool at the organization level, which serves as the administrative boundary for managing external identities. Inside this pool, administrators configure one or more workforce identity pool providers using standard industry protocols:
While workforce identity federation manages human access, machine-to-machine communication for applications hosted outside Google Cloud relies on workload identity federation.
Once trust is established, attribute mapping translates incoming claims from the external IdP into Google Cloud principal attributes. Mapping the google.subject attribute is required because it defines the unique principal identifier written to Cloud Audit Logs. Administrators should always map google.subject to immutable, non-reusable claims rather than mutable values like email addresses to prevent account spoofing. Optional target attributes include google.groups for group-based access and google.display_name for user identification in the Google Cloud console.
Administrators use Common Expression Language (CEL) to transform and filter claims up to a total mapping limit of 16 KB. Because SAML assertions supply attributes as lists by default, any target expecting a single value must extract an element by index, whereas google.groups accepts a list of strings. Common CEL operations include:
join functionsplit functionIf an incoming assertion contains more than 400 groups, the sign-in request fails automatically unless group filtering expressions are applied.
An attribute condition is an optional boolean CEL expression evaluated before Google Cloud issues short-lived session credentials. This condition acts as an authorization gate, checking incoming assertions against criteria such as corporate group membership, IP address ranges, or multifactor authentication status. Evaluating conditions is critical when integrating with multi-tenant IdPs that share a single issuer URL. By rejecting unauthorized tenants before token generation, attribute conditions prevent the confused deputy problem and stop unauthorized token reuse.
Google Cloud uses standardized principal identifiers to bind IAM roles directly to federated identities without storing user profiles. These identifiers are used in standard IAM commands, such as gcloud projects add-iam-policy-binding, to enable attribute-based access control (ABAC). Administrators grant permissions at various scopes using specific identifier patterns:
principal://iam.googleapis.com/locations/global/workforcePools/POOL_ID/subject/SUBJECT_ATTRIBUTE_VALUEprincipalSet://iam.googleapis.com/locations/global/workforcePools/POOL_ID/group/GROUP_IDprincipalSet://iam.googleapis.com/locations/global/workforcePools/POOL_ID/attribute.ATTRIBUTE_NAME/ATTRIBUTE_VALUEprincipalSet://iam.googleapis.com/locations/global/workforcePools/POOL_ID/*Administrators control credential lifetimes by setting the session duration at the workforce pool level. This duration determines how long temporary access tokens, Cloud Console sessions, and Google Cloud CLI sessions remain valid. The configuration allows a range from 15 minutes (900 seconds) up to 12 hours (43,200 seconds), with a default lifetime of 1 hour (3,600 seconds). Shorter session windows reduce the risk of compromised tokens, while longer windows reduce re-authentication interruptions for users during active tasks.
Prepare and test your skills
Prepare and test your skills
Workforce identity federation manages access for human users such as employees, contractors, and partners using external corporate credentials, whereas workload identity federation manages machine-to-machine communication for applications hosted outside Google Cloud. Workforce federation delegates authentication decisions to an external identity provider (IdP) using protocols such as SAML 2.0 or OpenID Connect (OIDC).
Mapping the google.subject attribute is required because it defines the unique principal identifier written to Cloud Audit Logs. Administrators should always map this attribute to an immutable, non-reusable claim rather than a mutable value like an email address to prevent account spoofing.
Attribute conditions evaluate boolean Common Expression Language (CEL) expressions against incoming assertions before Google Cloud issues short-lived session credentials. When integrating with multi-tenant external identity providers that share a single issuer URL, these conditions reject unauthorized tenants prior to token generation, preventing unauthorized token reuse.
Workforce identity pool session durations can be configured from 15 minutes (900 seconds) up to 12 hours (43,200 seconds), with a default lifetime of 1 hour (3,600 seconds). This duration setting dictates how long temporary access tokens, Cloud Console sessions, and Google Cloud CLI sessions remain valid.
Execute gcloud iam workforce-pools create-login-config locations/global/workforcePools/WORKFORCE_POOL_ID/providers/PROVIDER_ID --output-file=login.json.
Execute gcloud auth application-default login --scopes="https://www.googleapis.com/auth/cloud-platform" --client-id-file="client_secret.json".
Execute gcloud config set auth/login_config_file "https://iam.googleapis.com/v1/workforcePools/WORKFORCE_POOL_ID/providers/PROVIDER_ID".
Execute gcloud iam workforce-pools create-cred-config locations/global/workforcePools/WORKFORCE_POOL_ID/providers/PROVIDER_ID --subject-token-type="urn:ietf:params:oauth:token-type:id_token" --credential-source-file="id_token.json" --workforce-pool-user-project="PROJECT_NUMBER" --output-file="config.json".
A security engineer is configuring Workforce Identity Federation to grant external contractors access to Google Cloud resources using their corporate OpenID Connect (OIDC) identity provider, eliminating the need to synchronize user accounts to Cloud Identity.
After creating the workforce pool and configuring the OIDC provider with the appropriate issuer URL, client ID, client secret, and attribute mappings, the engineer must enable the contractors to authenticate securely through the Google Cloud CLI (gcloud) using interactive browser-based sign-in.
Which command should the security engineer execute to generate the configuration file required for browser-based sign-in?