Google APIs
Jump to navigation
Jump to search
Access Control
- Authenication
- Principal: entity/identity that can be granted access to a resource. Two types
- User accounts are managed as Google Accounts and are for a developer, admin or other person interacting with Google Cloud
- Service accounts are managed by IAM and are non-human users. For applications needing access to App Engine or Compute Engine instances
- Applications
- Google Cloud APIs only accept requests from registered applications. Application credentials are required in the form of
- API keys
- OAuth 2.0 client credentials, or
- service account keys
Service Accounts
- special type of Google account intended to represent a non-human user that needs to authenticate and be authorized to access data in Google APIs.
- Your application assumes the identity of the service account to call Google APIs, so that the users aren't directly involved.
- What resources? What permissions? Where (local or in cloud)?
- Service accounts are both
- a resource, that can grant roles to other users to access or manage the service account, and
- an identity, which can grant a role to a service account and allow it to access a resource
- E.g.: app running on Compute Engine should only have access to create objects in Cloud Storage: grant it Storage Object Creator role
- Over time, service accounts can accumulate. Name them well. Disable them often. Names should be unique for best performance
Permissioning Use Cases
- as usual, grant minimum set of permissions per service account. (The default service accounts for Compute and App Engine are especially liberal/dangerous.)
- Attaching service accounts to resources:
- Permissions:
iam.serviceAccounts.actAs
- Permissions:
- Directly impersonating a service account:
- Permissions:
iam.serviceAccounts.getAccessToken, .signBlob, .signJwt, .implicitDelegation - Roles:
roles/iam.serviceAccountTokenCreator
- Permissions:
- Once permissions are granted, a user or service can impersonate the identity of a service account if
- the user gets short-term credentials for the service account using the
.getAccessToken()method - user get artifacts signed by Google-managed private key of the service account using the
iam.serviceAccounts.signBlobpermission and calling either thesignBlob()orsignJwtmethods - user may impersonate account without retrieving a credential. Only supported for
generateAccessToken()method - Generating OpenID Connect (OIDC) ID tokens: