Skip to Content
0
Jan 26, 2021 at 09:05 AM

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

287 Views

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"
    }
  ]
}