This document describes how to authenticate to Google Cloud by using tokens through Workload Identity Federation. With Workload Identity Federation, you can grant on-premises or multicloud SAP workloads access to Google Cloud resources without using a service account key.
Workload Identity Federation follows the OAuth 2.0 token exchange specification. You provide a credential from your IdP to the Security Token Service, which verifies the identity on the credential, and then returns a federated access token in exchange. You can use this federated access token directly with supported services or use it to impersonate a service account and obtain a short-lived access token. The short-lived access token lets you call any Google Cloud APIs that the service account has access to.
You can use Workload Identity Federation with metadata server or external identity provider (IdPs).
Workload Identity Federation with VM metadata
If your SAP system is hosted on Google Cloud but managed by SAP, then you can use Workload Identity Federation to securely access resources in other Google Cloud projects from your SAP system. Workload Identity Federation lets your SAP system authenticate to other Google Cloud projects by using the VM metadata. This eliminates the need to manage service account keys, enhancing security and simplifying authentication.
The high-level configuration steps are as follows:
- In Google Cloud, configure Workload Identity Federation.
- In Google Cloud, create a service account.
- In Google Cloud, grant the service account access to the Workload Identity Federation pool.
- In ABAP SDK for Google Cloud, configure client key.
Configure Workload Identity Federation
To get the permissions that you need to configure Workload Identity Federation, ask your administrator to grant you the following IAM roles on the project:
- Workload Identity Pool Admin (
roles/iam.workloadIdentityPoolAdmin
) - Service Account Admin (
roles/iam.serviceAccountAdmin
)
For more information about granting roles, see Manage access.
To configure Workload Identity Federation, perform the following steps:
In the Google Cloud console, go to the New workload provider and pool page.
In the Create an identity pool section, enter a value for the following fields:
- Name: name for the pool. The name is also used as the pool ID. You can't change the pool ID later.
- Description: text that describes the purpose of the pool.
Click Continue.
Under Add a provider to pool, add the metadata server as a provider:
- In the Select a provider field, select OpenID Connect (OIDC).
Enter the following provider details:
- Provider name: enter a name for the provider.
- Issuer(URL): enter the metadata server token URL,
https://accounts.google.com
. - Audience: select Allowed audience and enter the Google Cloud project number of the Google Cloud project that you need to access. For information about how to get the project number, see Gather details of Google metadata server instance.
Click Continue.
Under Configure provider attributes, do the following:
- In the Google 1 field, make sure the value is
google.subject
. - In the OIDC 1 field, enter
assertion.sub
.
- In the Google 1 field, make sure the value is
Click Save.
Make a note of the following:
- Pool ID
- Provider ID
You need these IDs when configuring the client key.
Gather details of Google metadata server instance
To get the Google metadata server instance details that you need to configure the Workload Identity Federation, perform the following steps:
-
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG. - Click ABAP SDK for Google Cloud > Utilities > Get specific metadata values for Google Metadata Server Instance.
- Select the options as appropriate:
- Numeric Project ID
- Default Service Account Email
- Click Execute to view the details.
- Make a note of the details. You need them when configuring Workload Identity Federation in the Google Cloud console.
Create a service account
In the Google Cloud console, create an IAM service account. This service account must be a principal in the Google Cloud project that contains the Google Cloud APIs that you plan to consume using the SDK.
In the Google Cloud console, select the project where you want to create the service account.
If you create the service account in the same project that contains the Google Cloud APIs, then the service account is added as a principal to the project automatically.
If you create the service account in a project other than the project where the Google Cloud APIs are enabled, then you need to add the service account to that project in an additional step. For more information, see Add the service account to the Google Cloud project.
Create a service account for authentication and authorization to access Google Cloud APIs.
For information about how to create a service account, see Create a service account.
In the Google Cloud console, grant the service account the required IAM roles to access the API functionality. To understand the role requirement for Google Cloud APIs, see the individual API documentation and follow the principle of least privilege. For more information about API specific predefined roles, see IAM basic and predefined roles reference.
If you created the service account in a different project than the project that contains the Google Cloud APIs that you plan to consume using the SDK, then note the name of the service account. You specify the name when you add the service account to that project.
Add the service account to the Google Cloud project
If you created the service account for ABAP SDK for Google Cloud in a project other than the project that contains the Google Cloud APIs that you plan to consume using the SDK, then you need to add the service account to the Google Cloud project that contains the Google Cloud APIs.
If you created the service account in the same project that contains the Google Cloud APIs, then you can skip this step.
To add an existing service account to the Google Cloud project that contains the Google Cloud APIs, perform the following steps:
In the Google Cloud console, go to the IAM Permissions page.
Confirm that the name of the project that contains the target Google Cloud APIs is displayed near the top of the page. For example:
Permissions for project '
PROJECT_NAME
'If it is not, then switch projects.
On the IAM Permissions page, click
Grant access.In the Grant access to '
PROJECT_NAME
' dialog that appears, perform the following steps:- In the New principals field, specify the name of the service account.
In the Select a role field, specify a relevant role. For example, for Pub/Sub, to modify topics and subscriptions, and access to publish and consume messages, you can specify the role Pub/Sub Editor (
roles/pubsub.editor
).For more details about API specific predefined roles, see IAM basic and predefined roles reference.
Add additional roles as required for your API usage. We recommend implementing the principle of least privilege.
Click Save. The service account appears in the list of project principals on the IAM page.
The service account can now be used to access Google Cloud APIs in this project.
Grant the service account access to the Workload Identity Federation pool
To impersonate service accounts from federated workloads, grant the
Workload Identity User (roles/iam.workloadIdentityUser
)
on the service account. For more information about granting roles, see Manage access.
To grant the service account access to the Workload Identity Federation pool, perform the following:
In the Google Cloud console, go to the Workload Identity Pools page.
Select the workload identity pool that you created in the configure Workload Identity Federation section.
To grant access to the workload identity pool, click
Grant access.In the Service account list, select the service account that has access to Google Cloud APIs. If you use multiple service accounts, then add them all here.
In the Attribute name field, select Subject.
In the Attribute value field, enter the service account email address retrieved from the metadata server, in double quotes. For example,
"svc-acct-compute@example-project-123456.iam.gserviceaccount.com"
.For information about how to retrieve the service account email address from the metadata server, see Gather details of Google metadata server instance.
In the Configure your application dialog that appears, click Dismiss.
Configure client key
-
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG. - Click ABAP SDK for Google Cloud > Basic Settings > Configure Client Key.
- Click New Entries.
Enter values for the following fields:
Field Description Google Cloud Key Name Specify a name of the client key configuration. Google Cloud Service Account Name Specify the name of the service account, in email address format, that was created to access Google Cloud APIs in the step Create a service account. For example: sap-example-svc-acct@example-project-123456.iam.gserviceaccount.com
.Google Cloud Scope Specify the API access scope, https://www.googleapis.com/auth/cloud-platform
.Google Cloud Project Identifier Specify the ID of the Google Cloud project where you created the workload identity pool. Command name Leave this field blank. Authorization Class Specify the authentication class as appropriate: /GOOG/CL_AUTH_WIF_META_ACCESS
: Generates Google-signed OAuth tokens./GOOG/CL_AUTH_WIF_META_IDTOKEN
: Generates Google-signed ID tokens.
Token Caching The flag that determines whether or not the access tokens retrieved from Google Cloud are cached.
We recommend that you enable token caching after you are done configuring and testing your connection to Google Cloud.
Token Refresh Seconds Leave this field blank. Authorization Parameter 1 Specify the workload identity pool ID. Authorization Parameter 2 Specify the workload identity provider ID. Save the entry.
Workload Identity Federation with external IdPs
You can use Workload Identity Federation with external IdPs such as Amazon Web Services (AWS) or with any identity provider (IdP) that supports OpenID Connect (OIDC), such as Microsoft Azure or SAML 2.0.
For authentication using tokens through Workload Identity Federation, the high-level configuration steps are as follows:
- Prepare your external IdP.
- In Google Cloud, configure Workload Identity Federation.
- In Google Cloud, create a service account.
- In Google Cloud, allow the external workload to impersonate the service account.
- In ABAP SDK for Google Cloud, implement ABAP code to retrieve security tokens from your IdP.
- In ABAP SDK for Google Cloud, configure client key.
Not all Google Cloud products support Workload Identity Federation. Before setting up authentication using Workload Identity Federation, review the list of supported products and limitations. For more information, see Workforce identity federation: supported products and limitations.
Prepare your external IdP
You need to prepare your IdP so that your SAP workload can obtain credentials that can be exchanged for a Google OAuth 2.0 security token.
To prepare your external IdP, perform the steps depending on your IdP:
- If you're using AWS or Azure as your IdP, then follow the instructions to prepare your external IdP.
- If you're using other IdPs, then follow the instructions to prepare your external IdP.
Configure Workload Identity Federation
In Google Cloud, configure workload identity pool and providers.
You configure an identity pool, which is an entity that lets you manage external identities. You also configure a workload identity pool provider, which is an entity that describes a relationship between Google Cloud and your IdP.
To configure Workload Identity Federation, perform the steps depending on your external IdP:
- If you're using AWS or Azure as your IdP, then follow the instructions to create the workload identity pool and provider.
- If you're using other IdPs, then follow the instructions to create the workload identity pool and provider.
Make a note of the following:
- Project number: the project number of the Google Cloud project where you created the workload identity pool.
- Pool ID: a unique ID that identifies the workload identity pool.
- Provider ID: an ID that identifies the workload identity pool provider.
You need them for the ABAP SDK client key configuration.
Create a service account
In Google Cloud console, create a dedicated IAM service account to access Google Cloud APIs. This service account must be a principal in the Google Cloud project that contains the Google Cloud APIs that you plan to consume using the SDK.
In the Google Cloud console, enable the IAM Service Account Credentials API, Security Token Service API, and any other supported APIs that you plan to access using the SDK.
For information about how to enable Google Cloud APIs, see Enabling APIs.
Create a service account that represents the workload.
Grant the service account the required IAM roles to access the API functionality. To understand the role requirement for Google Cloud APIs, see the individual API documentation and follow the principle of least privilege. For more information about API specific predefined roles, see Find IAM roles for Google Cloud APIs.
Allow the external workload to impersonate the service account
To allow the external workload to impersonate the service account, perform the steps depending on your external IdP:
- If you're using AWS or Azure as your IdP, then follow the instructions to allow the external workload to impersonate the service account.
- If you're using other IdPs, then follow the instructions to allow the external workload to impersonate the service account.
Implement ABAP code to retrieve security tokens from your IdP
ABAP SDK for Google Cloud provides an abstract class /GOOG/CL_AUTH_WIF_BASE
,
which has the logic to retrieve OAuth 2.0 security tokens from
the Security Token Service and OAuth 2.0 access tokens from the
IAM Service Account Credentials API. As a developer, you need to
create a child class in your namespace that inherits
from the abstract class /GOOG/CL_AUTH_WIF_BASE
.
To invoke Cloud Run functions from the ABAP SDK for Google Cloud by using
Workload Identity Federation,
the SDK provides another abstract class
/GOOG/CL_AUTH_WIF_ID_TOKEN
. If you set up authentication by using
Workload Identity Federation, then you need to create one more
child class in your namespace that inherits from the abstract class
/GOOG/CL_AUTH_WIF_ID_TOKEN
. You specify this child class in
the Authorization Class field while configuring client key to invoke Cloud Run functions.
Make sure to implement the
method GET_EXT_IDP_TOKEN
in the child class and write the logic to get the
security token from your IdP. Populate the following fields:
CV_TOKEN
: the token retrieved from your IdP in thestring
format.CV_TOKEN_TYPE
: the type of the security token retrieved from your IdP. The supported token types are:urn:ietf:params:oauth:token-type:jwt
urn:ietf:params:oauth:token-type:id_token
urn:ietf:params:aws:token-type:aws4_request
urn:ietf:params:oauth:token-type:access_token
urn:ietf:params:oauth:token-type:saml2
The values populated in CV_TOKEN
and CV_TOKEN_TYPE
are then used by methods of
the abstract class /GOOG/CL_AUTH_WIF_BASE
to exchange and retrieve the
final OAuth 2.0 token, which is used in the API calls.
The following example shows the sample implementations of method
GET_EXT_IDP_TOKEN
for
other Cloud providers such as AWS and Azure.
AWS
Azure
Configure client key
-
In SAP GUI, execute the transaction code
/GOOG/SDK_IMG
.Alternatively, execute the transaction code
SPRO
, and then click SAP Reference IMG. - Click ABAP SDK for Google Cloud > Basic Settings > Configure Client Key.
- Click New Entries.
Enter values for the following fields:
Field Description Google Cloud Key Name Specify a name of the client key configuration. Google Cloud Service Account Name Specify the name of the service account, in email address format, that was created to access Google Cloud APIs in the step Create a service account. For example: sap-example-svc-acct@example-project-123456.iam.gserviceaccount.com
.Google Cloud Scope Specify the API access scope, https://www.googleapis.com/auth/cloud-platform
.Google Cloud Project Identifier Specify the ID of the Google Cloud project where you created the workload identity pool. Command name Leave this field blank. Authorization Class Specify the child class, which contains the implementation of class /GOOG/CL_AUTH_WIF_BASE
. For more information, see Implement ABAP code to retrieve security tokens from your IdP.Token Caching The flag that determines whether or not the access tokens retrieved from Google Cloud are cached.
We recommend that you enable token caching after you are done configuring and testing your connection to Google Cloud.
Token Refresh Seconds Leave this field blank. Authorization Parameter 1 Specify the workload identity pool ID. Authorization Parameter 2 Specify the workload identity provider ID. Save the entry.
Get support
If you need help resolving problems with the ABAP SDK for Google Cloud, then do the following:
Refer to the ABAP SDK for Google Cloud troubleshooting guide.
Ask your questions and discuss ABAP SDK for Google Cloud with the community on Cloud Forums.
Collect all available diagnostic information and contact Cloud Customer Care. For information about contacting Customer Care, see Getting support for SAP on Google Cloud.