cancel
Showing results for 
Search instead for 
Did you mean: 

Logout From Standalone SAPUI5 App (HTML5 repository) in Cloud Foundry

former_member662960
Participant
0 Kudos

Dear Community,

We have a SAPUI5 app and we need to implement the logout feature in it as it won't be part of the portal. The app is communicating with the backend service via the approuter and is deployed using html5 repository.

We are able to logout the user by calling the logout endpoint using window.location.replace('/do/logout'), but we are not being able to redirect the user to our custom logout page. Only the central login page appears after logout.

If we try to do a AJAX call to the logout endpoint the session cookies are kept, no real logout happens. Navigating back to the app we are able to access the it without relogin.

How can we avoid using the window.location (as our static code checks will complain about this) and redirect the user to a custom logout page?

Here is our xs-app.json:

{
  "welcomeFile": "index.html",
  "authenticationMethod": "route",
  "logout": {
    "logoutEndpoint": "/do/logout"
  },
  "routes": [
    {
      "source": "^/rest(.*)$",
      "target": "$1",
      "authenticationType": "xsuaa",
      "scope": [
        "$XSAPPNAME.SettingsRead",
        "$XSAPPNAME.PartitioningCreateInitial",
        "$XSAPPNAME.LogEventsRead",
        "$XSAPPNAME.ChartExecute"
      ],
      "destination": "etd-cloud-rest"
    },
    {
      "source": "^/internal/rest/(.*)$",
      "target": "/internal/$1",
      "authenticationType": "xsuaa",
      "scope": [
        "$XSAPPNAME.TenantSelect"
      ],
      "destination": "etd-cloud-rest"
    },
    {
      "source": "^/odata(.*)$",
      "target": "$1",
      "authenticationType": "xsuaa",
      "scope": [
        "$XSAPPNAME.SettingsRead",
        "$XSAPPNAME.SettingsManageEventStorageWrite",
        "$XSAPPNAME.SettingsTimeZoneWrite",
        "$XSAPPNAME.SettingsRetentionPeriodWrite",
        "$XSAPPNAME.ValuelistRead",
        "$XSAPPNAME.ValuelistWrite",
        "$XSAPPNAME.LogEventsRead",
        "$XSAPPNAME.AlertsRead"
      ],
      "destination": "etd-cloud-odata"
    },
    {
      "source": "^/internal/odata/(.*)$",
      "target": "/internal/$1",
      "authenticationType": "xsuaa",
      "scope": [
        "$XSAPPNAME.TenantSelect"
      ],
      "destination": "etd-cloud-odata"
    },
    {
      "source": "^/query(.*)$",
      "target": "$1",
      "authenticationType": "xsuaa",
      "destination": "etd-cloud-query"
    },
    {
      "source": "^/internal/query/(.*)$",
      "target": "/internal/$1",
      "authenticationType": "xsuaa",
      "scope": [
        "$XSAPPNAME.TenantSelect"
      ],
      "destination": "etd-cloud-query"
    }
  ]
}

Accepted Solutions (0)

Answers (2)

Answers (2)

Hi Luisa,

You say that your application uses html5 apps repo but I don't see any route in xs-app.json that points to, for example:

{
"source": "^(/.*)","target": "$1","service": "html5-apps-repo-rt","authenticationType": "xsuaa"}
former_member662960
Participant
0 Kudos

Hi Sergio,

It is only present in the xs-app.json of our sapui5 app. Should we also add it to approuter?

0 Kudos

Hi Luisa,

Oh, this is the central approuter xs-app.json. Then why you have all these routes in central xs-app.json?. All html5 application routes (to html5 application backend) should be placed in the html5 application xs-app.json.

If you modeled it that way because it did not work for you it is probably because your ui is sending requests with absolute URLs --> for example dataSource: odata/.. (without leading slash).