Skip to Content
0
Aug 25, 2020 at 06:44 AM

No UAA configuration is provided in non-anonymous mode in HANA Node js module

511 Views

Hi all,

Good day..!

I am trying to build a Node.js (XSJS service and xsOdata service) for my UI5 application in HANA XSA Webide (HANA 2 SPS05) i have created the UAA xs-security.json file as below and added a instance in the HANA cockpit.

xs-security.json:

{
    "xsappname": "PAL_Customer360",
    "scopes": [
        {
            "name": "$XSAPPNAME.Display",
            "description": "display"
        },
        {
            "name": "$XSAPPNAME.Create",
            "description": "create"
        },
        {
            "name": "$XSAPPNAME.Edit",
            "description": "edit"
        },
        {
            "name": "$XSAPPNAME.Delete",
            "description": "delete"
        }
    ],
    "attributes": [
        {
            "name": "manager",
            "description": "manager",
            "valueType": "s"
        }
    ],
    "role-templates": [
        {
            "name": "Viewer",
            "description": "View all records",
            "scope-references": [
                "$XSAPPNAME.Display"
            ],
            "attribute-references": [
                "manager"
            ]
        },
        {
            "name": "Editor",
            "description": "Edit and Delete records",
            "scope-references": [
                "$XSAPPNAME.Create",
                "$XSAPPNAME.Edit",
                "$XSAPPNAME.Delete",
                "$XSAPPNAME.Display"
            ],
            "attribute-references": [
                "manager"
            ]
        }
    ]
}

and the same has binded with mta.yaml as below,

- name: xsjs_customer360
    type: nodejs
    path: xsjs_customer360
    requires:
      - name: db_cust360
      - name: hdi_db_cust360
      - name: PAL_Customer360-uaa
    provides:
      - name: xsjs_customer360_api
        properties:
          url: '${default-url}'
  - name: Z_Customer_360
    type: html5
    path: Z_Customer_360
    requires:
      - name: xsjs_customer360_api
        group: destinations
        properties:
          name: xsjs-backend
          url: '~{url}'
          forwardAuthToken: true
      - name: PAL_Customer360-uaa

and i commented out the anonymous mode in server.js as below,

/*eslint no-console: 0, no-unused-vars: 0*/
"use strict";


var xsjs  = require("@sap/xsjs");
var xsenv = require("@sap/xsenv");
var port  = process.env.PORT || 3000;


var options = {
	//anonymous : true, // remove to authenticate calls
	auditLog : { logToConsole: true }, // change to auditlog service for productive scenarios
	redirectUrl : "/index.xsjs"
};


// configure HANA
try {
	options = Object.assign(options, xsenv.getServices({ hana: {tag: "hana"} }));
} catch (err) {
	console.log("[WARN]", err.message);
}


// configure UAA
try {
	 options = Object.assign(options, xsenv.getServices({ uaa: {tag: "xsuaa"} }));
} catch (err) {
	console.log("[WARN]", err.message);
}


// start server
xsjs(options).listen(port);


console.log("Server listening on port %d", port);

When we make anonymous false or removed we are getting a error "No UAA configuration is provided in non-anonymous mode" as below,

And Made In the UI module i have added routing the xs-app.json as below,

{
	"welcomeFile": "webapp/index.html",
	"authenticationMethod": "route",
	"routes": [{
			"source": "(.*)(.xsjs)",
			"destination": "xsjs-backend",
			"csrfProtection": false,
			"authenticationType": "xsuaa"
		}, {
			"source": "(.*)(.xsodata)",
			"destination": "xsjs-backend",
			"authenticationType": "xsuaa"


		}, 
		{
			"source": "^/(.*)(.xsjs)",
			"destination": "xsjs-backend",
			"authenticationType": "xsuaa"
		},
		{
			"source": "^/xsodata/(.*)",
			"destination": "xsjs-backend",
			"authenticationType": "xsuaa",
			"scope" : "$XSAPPNAME.Display"
		},
		{
			"source": "^/(.*)$",
    		"localDir" : "resources"
		}


	]
}

When i run the UI Module we are facing the below error,

This above both error's happen only when i set anonymous :"false" or removed it, but working fine in anonymous : "true", Kindly help me fixing this error.

Thanks,

Bharani

Attachments

errornodejs.jpg (155.9 kB)
errorui.png (410.7 kB)