SAP / cf-html5-apps-repo-cli-plugin

Cloud Foundry CLI plugin to work with SAP Cloud HTML5 Applications Repository
Apache License 2.0
43 stars 5 forks source link

Issue-After deployment not able to get the URL for the deployed HTML5 app. #46

Closed Askullu closed 3 years ago

Askullu commented 3 years ago

Description

Issue- After deployment not able to get the URL for the deployed HTML5 app.

Steps to Reproduce:

1) Create a dev space of "SAP Fiori" type and with "Launchpad Module" extension. 2) Clone the project from https://github.tools.sap/I537413/s4extendui and run "npm install" 3) Click on Terminal --> New Terminal and navigate if required to the project root folder 4) Run the command "mbt build" 5) Once the build over, right-click mta_archives >S4-extendui_0.0.1.mtar and select Deploy MTA Archive 6) In terminal run "cf html5-list -d -u"

The build and deployment happened successfully without any error screenshot has been attached. But after deployment when we run "cf html5-list -d -u" we can't see the url of the application and the destinations which are supposed to be created are not getting created.

MicrosoftTeams-image (13) MicrosoftTeams-image (12)

Note: Observed code change in the mta.yml file when compared with the previous execution. OId mta file has been attached for reference OldMTA.txt

Expected result: It should display the URL of the deployed application and the destination should be created.

Actual result: Not displaying the URL of the deployed application and the destination not getting created.

Environment

CLI Output

Set environment variable DEBUG=1, run the flow and paste output here. DEBUG=1 cf html5-list -d -u 09:42:50.393024 Running CloudFoundry html5-plugin 1.4.5 09:42:50.393067 Initializing command 'html5-list' 09:42:50.393081 Configuration file does not exist. No cache to clear 09:42:50.393100 Executing command 'html5-list': args: '[-d -u]' 09:42:50.393122 Listing HTML5 applications available via destinations 09:42:50.393133 Getting context (org/space/username) Getting list of HTML5 applications available via destinations in org CustomUI53 / space dev as akanksha.sherrie.kullu@sap.com... 09:42:50.394301 Getting HTML5 context 09:42:50.394312 Getting list of services 09:42:50.394653 Making request to: /v2/spaces/f21b9c85-45a5-4335-87ba-74af03d44579/services 09:42:50.683554 Looking for 'html5-apps-repo' service 09:42:50.683580 Getting service plans for 'html5-apps-repo' service (GUID: 73210b64-6f92-4a16-bd1c-401f00cbe597) 09:42:50.683588 Making request to: /v2/service_plans?q=service_guid:73210b64-6f92-4a16-bd1c-401f00cbe597 09:42:50.879420 Looking for app-runtime service plan 09:42:50.879439 Getting service instances of 'html5-apps-repo' service app-runtime plan (&{Name:app-runtime GUID:74b88153-e9ad-4f5f-b2df-3a65923c1a80}) 09:42:50.879468 Making request to: /v2/service_instances?q=service_plan_guid%20IN%2074b88153-e9ad-4f5f-b2df-3a65923c1a80%3Bspace_guid:f21b9c85-45a5-4335-87ba-74af03d44579 09:42:50.954904 Creating service instance of html5-apps-repo service app-runtime plan 09:42:50.954925 Making request to: /v2/service_instances 09:42:52.066711 Getting list of service keys for service app-runtime-1609753370 09:42:52.066729 Making request to: /v2/service_instances/1c9b6a04-2a2d-4e1a-9a51-bd561afcc5a2/service_keys 09:42:52.146233 Creating service key for app-runtime-1609753370 service 09:42:52.146260 Making request to: /v2/service_keys 09:42:52.906005 Getting token for service key html5-key-1609753372 09:42:52.906031 Making request to: https://customui53.authentication.sap.hana.ondemand.com/oauth/token 09:42:53.159763 Access token for service key html5-key-1609753372: [ SENSITIVE DATA ] 09:42:53.159805 Getting list of services 09:42:53.160394 Returning cached list of services 09:42:53.160406 Looking for 'destination' service 09:42:53.160410 Destination service found: &{Name:destination GUID:be381e3b-0d69-47bc-a044-63f69733acfe} 09:42:53.160420 Getting service plans for 'destination' service (GUID: be381e3b-0d69-47bc-a044-63f69733acfe) 09:42:53.160425 Making request to: /v2/service_plans?q=service_guid:be381e3b-0d69-47bc-a044-63f69733acfe 09:42:53.377231 Destination service 'lite' plan found: &{Name:lite GUID:821497d5-8d07-4748-bf78-48495eec823b} 09:42:53.377264 Getting service instances of 'destination' service 'lite' plan (&{Name:lite GUID:821497d5-8d07-4748-bf78-48495eec823b}) 09:42:53.377283 Making request to: /v2/service_instances?q=service_plan_guid%20IN%20821497d5-8d07-4748-bf78-48495eec823b%3Bspace_guid:f21b9c85-45a5-4335-87ba-74af03d44579 09:42:53.591107 Using service instance of 'destination' service 'lite' plan: {Name:s4-extendui-destination-service GUID:5cdb7ad3-d1cc-49cf-afcc-8344e81c290b UpdatedAt:2020-12-30T06:16:11Z LastOperation:{Type:update State:succeeded Description: UpdatedAt:2021-01-04T09:20:30Z CreatedAt:2021-01-04T09:20:30Z}} 09:42:53.591147 Creating service key for 'destination' service 'lite' plan 09:42:53.591159 Making request to: /v2/service_keys 09:42:54.478264 Getting token for service key html5-key-1609753373 09:42:54.478284 Making request to: https://customui53.authentication.sap.hana.ondemand.com/oauth/token 09:42:54.647458 Access token for service key html5-key-1609753373: [ SENSITIVE DATA ] 09:42:54.647486 Making request to: https://destination-configuration.cfapps.sap.hana.ondemand.com/destination-configuration/v1/subaccountDestinations/ 09:42:54.668176 List of subaccount destinations: [{Name:bupa Description: Type:HTTP URL:http://s4h:443/sap/opu/odata/sap/API_BUSINESS_PARTNER Authentication:PrincipalPropagation ProxyType:OnPremise TokenServiceURL: TokenServiceURLType: ClientID: ClientSecret: Properties:map[HTML5.DynamicDestination:true WebIDEAdditionalData:full_url WebIDEEnabled:true WebIDEUsage:odata_gen sap-client:100]}] 09:42:54.668220 Processing destination: {Name:bupa Description: Type:HTTP URL:http://s4h:443/sap/opu/odata/sap/API_BUSINESS_PARTNER Authentication:PrincipalPropagation ProxyType:OnPremise TokenServiceURL: TokenServiceURLType: ClientID: ClientSecret: Properties:map[HTML5.DynamicDestination:true WebIDEAdditionalData:full_url WebIDEEnabled:true WebIDEUsage:odata_gen sap-client:100]} 09:42:54.668239 Deleting service key html5-key-1609753373 09:42:54.668251 Making request to (try 1/3): /v2/service_keys/0a3a7e11-8af9-4136-8db0-d65a6af1f39a 09:42:55.105162 Deleting service key html5-key-1609753372 09:42:55.105194 Making request to (try 1/3): /v2/service_keys/cf16f8fe-1aca-4557-a9bd-1d853abf7c04 09:42:55.581883 Deleting service instance app-runtime-1609753370 09:42:55.581910 Making request to (try 1/3): /v2/service_instances/1c9b6a04-2a2d-4e1a-9a51-bd561afcc5a2?recursive=true 09:42:56.473739 Service instance app-runtime-1609753370 successfully deleted OK

name version app-host-id service name destination name last changed url
09:42:56.473859 Disposing command 'html5-list'

micellius commented 3 years ago

@Askullu , thanks for reporting an issue! Looks like you are using destination configuration on service instance level:

modules:
- name: s4-extendui-destination-content
  type: com.sap.application.content
  requires:
  - name: s4-extendui-destination-service
    parameters:
      content-target: true
  ...
  parameters:
    content:
      instance: # <- instance level configuration
        destinations:
        - Name: bpServiceManaged_s4_extendui_html_repo_host
          ServiceInstanceName: s4-extendui-html5-app-host-service
          ServiceKeyName: s4-extendui_html_repo_host-key
          sap.cloud.service: bpServiceManaged

In this case you should use -di <destination_instance_name> instead of -d (which is for subaccount level destinations).

To see list of HTML5 applications exposed via service instance level destination configuration, you can run:

cf html5-list -di s4-extendui-destination-service -u

By default, the URLs will be for Portal service (with .cpp. subdomain). If you are subscribed to Launchpad and not to Portal, replace .cpp. with .launchpad. in the shown URLs, or use HTML5_RUNTIME_URL environment variable as described in the README.md file.

Askullu commented 3 years ago

Hi @micellius I had ran cf html5-list -di s4-extendui-destination-service -u the command I was able to get the url but when we launch it, it says Forbidden

3 4 5
micellius commented 3 years ago

@Askullu , HTTP 403 is a valid response that indicates that your user does not have sufficient privileges to access the requested resource.

To access static resources of nsBP application your user should have a BPViewer scope, which is part of BPViewerRole role. Make sure your user is assigned to corresponding role collection that has such role (e.g. BPViewerRC).

I cloned the repo you provided, built and deployed MTAR, listed HTML5 applications with CLI and was able to access the application with printed URL. So, if you experience an issue, it's most probably because of security misconfiguration or cached user session that was created before your user was assigned to role collection. After checking that your user has sufficient permissions, please try to access the HTML5 application in incognito mode of the browser (to make sure it will be the fresh login and there is no active session).

Screen Shot 2021-01-06 at 9 32 07 Screen Shot 2021-01-06 at 9 26 14
Askullu commented 3 years ago

@micellius, thanks it's working now able to access the application after adding the required role.