
This blog explains how to use BTP's capabilities to establish secure authentication between the SAP Continuous Integration and Delivery service and the Cloud Foundry runtime without sharing any kind of secret.
The blog comes in three sections:
Motivation: Why it is not a good idea to share secrets
If you're only interested in the "doing" part, feel free to skip directly to the walkthrough section.
Let's assume you have a development project that you want to build with the SAP Continuous Integration and Delivery service and then deploy to BTP Cloud Foundry.
For the deployment, some form of authentication is required between the SAP Continuous Integration and Delivery service and the runtime (Cloud Foundry). Often, this is done by sharing a secret piece of information with the SAP Continuous Integration and Delivery service. That can be a password, a service key, or a cryptographic private key.
But why is secret sharing actually a bad idea? Secret sharing is the little brother of the dreaded "secret sprawl". An organisation suffers from secret sprawl, if there are copies of secrets distributed over different places, leading to a loss of transparency and accountability. Secrets need to be changed, either in a planned way or (worst case) because of a security incident. To do so, one needs to know all the places where a secret is stored. Forget one, and an important technical user might be locked out.
You end up with an inventory of credentials and stored secrets, something which is—in my experience—hard to maintain.
How can we avoid this whole rigmarole? The best solution is to dispense with secret sharing altogether and to instead define a trust relation between two systems. Sometimes that is not possible, but if two services belong to the same platform, you should expect that it is.
A solution based on configured trust without secret sharing thus provides:
Enough chit-chat, let's do some work. Here is a step-by-step guide how SAP Continuous Integration and Delivery can gain access to Cloud Foundry in order to deploy an application.
Let's start in the SAP Continuous Integration and Delivery service. Authentication in this service is modeled via credentials. We need a credential of type "Certificate-Based Authentication for Custom IdP":
The following data is required:
That's it. No secrets here!
Once you hit "Create" the detailed view appears:
There is the information we just entered plus two additional values:
These values are what we need in the next step.
You want your SAP Cloud Identity Services tenant to trust certificates generated by the SAP Continuous Integration and Delivery service. To enable that, login to the admin console of your tenant and navigate to "Tenant Settings > Authentication" > "Trusted Certificate Configuration". Click "Add".
For "Public Key", you can paste in the "Root Certificate" from the credential detail view. You can also paste any other valid certificate; it just does not matter.
The important value is the "Pattern". Paste in the pattern from the credential detail view. With the pattern the user email is extracted and the origin of the certificate (your SAP Continuous Integration and Delivery Service subscription) is checked. For more details on this, see the next section.
For more information, see the SAP Cloud Identity Service documentation.
The rest is routine. Either create a Cloud Foundry Environment job for you project or change an existing one to use you credential during the deployment. Here is an example for a deployment in the Acceptance stage:
That's it. Trigger your you job, lean back, and let the pipeline work for you.
In case the build fails with "Unauthorized" before the deployment, please log in to the admin console of your Cloud Identity Services tenant and navigate to "Tenant Settings" > Authentication" > "Certificate Authentication". Make sure that all check buttons are in OFF state.
To achieve secure authentication without secret sharing, we use asymmetric cryptography in the form of certificates. Here are the details:
Now let's shift our point of view to the SAP Cloud Identity Services tenant which has just received a certificate in a request for authentication. It will do the following:
CN=${mail}, L=CICD-c47ae4ee-59f4-4fcd-a692-7454ac9b71b7, OU=9abd6d5c-8ea7-49d4-ab08-a8dc776ada09, OU=SAP Cloud Platform Clients, O=SAP SE, C=DE
Let's look at the individual parts:
OU=9abd6d5c-8ea7-49d4-ab08-a8dc776ada09, OU=SAP Cloud Platform Clients, O=SAP SE, C=DE: These values in the DN are enforce by the CA. The UUID is the subaccount ID of the SAP Continuous Integration and Delivery service. The presence of this ID means that only certificates from that service will be accepted.
L=CICD-c47ae4ee-59f4-4fcd-a692-7454ac9b71b7: This value is provided by the SAP Continuous Integration and Delivery service. The UUID is the ID of the subaccount (owned by you) where your subscription to the service resides. This means that only certificates from this subaccount will be accepted.
Thanks for reading. I am happy for any kind of feedback, so let me know what you think!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
22 | |
13 | |
12 | |
7 | |
6 | |
6 | |
6 | |
5 | |
5 | |
5 |