SAP Home Learn Build Integrate Model Operate Extend with AI ConnectTutorial navigator Knowledge Graph API Devtoberfest Developer Advocates App Space

Manage my Account SAP Devs YouTube ↗ Learnings ↗ Community ↗ Provide Feedback ↗
Logout
โคข Open full site

Add Multitenancy to a Node.js Application Secured by the SAP Authorization and Trust Management service (XSUAA)

Learn how to add multitenancy to your application and make it available for other subaccounts using the SaaS Provisioning service and the XSUAA.

Overview

🎓 intermediate 45 min. SecurityIntermediateSAP Business Technology PlatformNode Js

You will learn

  • โœ”How to add multitenancy to a secure Node.js application
  • โœ”How to provide the application to another subaccount with the SaaS Provisioning service
  • โœ”How to access a multitenant application from another subaccount
Michael Shea M Michael Shea June 5, 2026
Created by July 14, 2023
Contributors

Prerequisites

Prerequisites

Steps

Intro

The use case for this tutorial is that you’ve created a Node.js application in your subaccount that is secured by the XSUAA. You now want to make that application available to other subaccounts (tenants). You’ll use the SaaS Provisioning service to make your application available to a consumer subaccount within your global trial account.

See the following diagram to get an overview of the SaaS architecture.

SaaS architecture
SaaS architecture
ย 

IMPORTANT: This tutorial is using specific values instead of placeholders. Please make sure to adapt those values to your own values, that you used in the previous tutorial.

The specific values that are used in this tutorial are:

  • The application name of the product list application: product-list.
    • Used in the manifest.yml.
  • The application name of the application router: approuter.
    • Used in the manifest.yml.
  • The route: product-list-ap25.cfapps.eu10.hana.ondemand.com.
    • Used in the manifest.yml.
    • Partially used in the config.json.
  • The route: approuter-product-list-ap25.cfapps.eu10.hana.ondemand.com.
    • Used in the manifest.yml.
    • Partially used in the index.js
  • The XSUAA service instance name: xsuaa-service-tutorial
    • Used in the manifest.yml.
    • Used when creating the service instance.
  • The SaaS Provisioning service instance name: saas-registry-tutorial.
    • Used in the manifest.yml.
    • Used when creating the service instance.
  • The XSUAA application name: product-list
    • Used in the config.json.
    • Used in the xs-security.json.
  • The subdomain Id of the consumer subaccount: consumer-tenant-ap25.
    • Used when creating the route for the consumer subaccount.

Step 1 Enable multitenancy in the security descriptor file
โ€”

To enable multitenancy, you need to change the parameter tenant-mode in the xs-security.json file to make it available for multiple tenants.

  1. Go to the product-list/security folder.

  2. Open the xs-security.json file.

  3. Change the value of the parameter tenant-mode to shared.

  4. Under scopes, add access to the SaaS Provisioning service to call the product list callback API directly. You’ll implement the callbacks in Step 3.

    JSON
    "scopes": [
    	{
    		"name": "$XSAPPNAME.read",
    		"description": "With this scope, USER can read products."
    	},
    	{
    		"name": "$XSAPPNAME.Callback",
    		"description": "With this scope set, the callbacks for tenant onboarding, offboarding and getDependencies can be called.",
    		"grant-as-authority-to-apps": [
    			"$XSAPPNAME(application,sap-provisioning,tenant-onboarding)"
    		]
    	}
    ],
  5. The redirect-uris parameter needs to have an asterisk right after the protocol and before approuter-product-list. This enables the application to redirect to the subscribed application instances in the other subaccounts.

    JSON
    "oauth2-configuration":     
    {        
      "redirect-uris": ["https://*approuter-product-list-ap25.cfapps.eu10.hana.ondemand.com/login/callback"]                
    }
  6. Save the file.

Step 2 Update the manifest
+
Step 3 Add a new routing pattern
+
Step 4 Add the service binding for the SaaS Provisioning service
+
Step 5 Implement the subscribe/unsubscribe endpoints
+
Step 6 Create a SaaS configuration file
+
Step 7 Delete the old XSUAA service instance
+
Step 8 Create service instances and redeploy your applications
+
Step 9 Create a route for a consumer subaccount
+
Step 10 Assign the role collection
+
Step 11 Troubleshooting
+

Resources

Discussion

Share feedback on this tutorial or join the conversation in SAP Community.

Submit detailed feedback Discuss in Community
Steps
Step 1 of 12
1. Enable multitenancy in the security descriptor file 2. Update the manifest 3. Add a new routing pattern 4. Add the service binding for the SaaS Provisioning service 5. Implement the subscribe/unsubscribe endpoints 6. Create a SaaS configuration file 7. Delete the old XSUAA service instance 8. Create service instances and redeploy your applications 9. Create a route for a consumer subaccount 10. Assign the role collection 11. Troubleshooting 12. Resources

Learn more →