abh1kg / sap-cf-multi-tenant-application

Sample Multi-tenant Cloud Application on SAP Cloud Foundry environment
MIT License
7 stars 2 forks source link

Developing a Multi-tenant Business Application on SAP Cloud Platform in the Cloud Foundry Environment

This repository contains a sample reference application for developing and deploying a SaaS (software-as-a-service) multitenant business application on SAP Cloud Platform Cloud Foundry environment. Follow the instructions below to deploy the application on SAP Cloud Platform in a subaccount that is configured for the Cloud Foundry environment. The sample application uses PostgreSQL and Redis as backing services.

Introduction to Multi-tenant Business Applications

As mentioned here:

"Multitenancy refers to a software architecture, in which tenants share the same technical resources, but keep the data separated and identity and access management for each tenant isolated."

A multi-tenant business application provides a suite of functional services to a group of customers. The developer and deployer of the application service (e.g. a company with a Global Account on SAP Cloud Platform) is often referred to as the provider while the customers of the service are referred to as consumers.

Prerequisites

Notes

We will use the Cloud Foundry CLI for deploying the applications onto the Cloud Foundry landscape. The process can be simplified further into a unified deployment experience using the concept of Multi-Target Archives (MTAs). This is left to the reader as an exercise in order to keep the concerns of deployment separate from the intention of developing a multi-tenant application.

Component Architecture

The following diagram illustrates the high-level component architecture for this application:

picture

Subscription Workflow

Runtime Workflow

Deploying the applications onto SAP Cloud Platform Cloud Foundry

cf api https://api.cf.eu10.hana.ondemand.com
cf login -u <email_address> -p <password> 
cf target -o <org_name> -s <space_name>
cf create-service postgresql <postgres_service_plan> <master_postgres_service_instance_name>

Note: Provisioning of a PostgreSQL instance is asynchronous in nature- please follow the instructions provided in the output for understanding the workflow.

cf create-service redis <redis_service_plan> <service_instance_name_for_redis_instance>
cf create-service xsuaa application <xsuaa_service_instance_name> -c security/xs-security-saas-provisioning.json
cf create-service xsuaa application <business_xsuaa_service_instance_name> -c security/xs-security-services.json

Utility Features

The repository provides two shell scripts inside this directory, which are described in detail below:

Using SAP Identity Authentication Service (formerly known as SAP Cloud Identity Service)

The users of the business application would generally be authenticated and stored in a custom Identity Realm, commonly called Identity Providers. This means that there needs to be security trust established between the SAP authorization service (service provider) and the identity provider itself.

The SAP Identity Authentication Service is a cloud service solution for secure authentication and user management in SAP cloud and on-premise applications. It provides a suite of services for authentication, single sign-on, and user management. The service provider's metadata can be downloaded from the consumer subaccount's authentication domain and uploaded to the Identity Authentication service to establish the first leg of trust. The second leg of trust needs to be established using the SAP Cloud Platform Cockpit Trust Configuration UI.

Once the trust configuration and two-way security initiative is set up, the Identity Authentication service can be used by the tenant administrator to set up relevant user groups, define user attributes, etc. The SAP Authorization component (XSUAA) is responsible for intercepting the user relevant information and passing it along to the target business application in an encoded format (JSON Web Token) using standard OAuth 2.0 protocol.