Skip to Content

Component Reuse - how to implement with XSUAA enabled in SAP Cloudfoundry?

I am trying to reuse a Component from an already published app on SAP Cloud Platform in Cloudfoundry. This concept seems to be working well making use of the destination service and when the published app has its security disabled. But once the security is enabled, the Component to be reused no longer loads as desired.

The desired outcome is a scenario where secure, simple and smaller apps with Components that can be reused are published on SCP, and there are other bigger, complex and secure apps which reuse the Components from the smaller, reusable published apps.

Component reuse using manifest.json is wonderful blog series by Jakob Marius Kjær demonstrating how SAPUI5 Component reuse can be implemented in SAP CP Neo environment.

For SAP Cloudfoundry environment, the same can be achieved using the destination service. We just need to add a route in xs-app.json of the myparentapp MTA which captures the resource root path and redirects it to the desired destination service. It could look like this:

{
   "source": "^/ui5/component-reuse/mychildapp/(.*)",
   "target": "$1",
   "destination": "mychildapp-route"
 }

The destination mychildapp-route can be created in the Cloudfoundry subaccount under Destinations. This destination would point to the deployed mychildapp's URL which is already running on the platform and has the SAPUI5 Component that we want to reuse.

This works very well when the mychildapp and myparentapp have security disabled. However, if we enable the security in these apps by setting authenticationMethod="route" in their respective xs-app.json file, the setup no longer works. The myparentapp correctly loads the Component.js of mychildapp using the ComponentContainer control but this file's contents look like this:

<html><head><link rel="shortcut icon" href="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" /><script>document.cookie="fragmentAfterLogin="+encodeURIComponent(location.hash)+";path=/";document.cookie="locationAfterLogin="+encodeURIComponent(location.pathname + location.search)+";path=/";document.cookie="signature=WCTmH8DW2TcRUEt32342tQpSU%3D;path=/";location="https://xxxxx.authentication.ap10.hana.ondemand.com/oauth/authorize?response_type=code&client_id=sb-mychildapp!t29&redirect_uri=https%3A%2F%2Fxxxxx-dev-myparentapp-ui5.cfapps.ap10.hana.ondemand.com%2Flogin%2Fcallback"</script></head></html>

The destination's authentication method is set to 'NoAuthentication'. I am thinking that the destination mychildapp-route needs to properly pass on already authenticated user details for myparentapp to the requested mychildapp.

The question is how do I implement it? Or if something else needs to be done, what is that?

Thanks!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

0 Answers