on 06-15-2021 12:24 PM
I am facing the below error when I run the API of the application involving Data Base calls
The complete log from the server
server.js file is:
/*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 || 5050;
xsenv.loadEnv();
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] Hana: ", err.message);
}
// configure UAA
try {
options = Object.assign(options, xsenv.getServices({ uaa: {tag: "xsuaa"} }));
} catch (err) {
console.log("[WARN] UAA: ", err.message);
}
// configure job scheduler
try {
options = Object.assign(options, xsenv.getServices({ jobs: {tag: "jobscheduler"} }));
} catch (err) {
console.log("[WARN] Job: ", err.message);
}
// start server
xsjs(options).listen(port);
console.log("Server listening on port %d", port);
xs-security file is:
{
"xsappname": "app",
"tenant-mode": "dedicated",
"description": "Security profile of called application",
"scopes": [
{
"name": "uaa.user",
"description": "UAA"
}
],
"role-templates": [
{
"name": "Token_Exchange",
"description": "UAA",
"scope-references": [
"uaa.user"
]
}
]
}
yaml file is:
_schema-version: '2.1'
ID: APP_CLOUD
version: 0.0.1
modules:
- name: CF_UI
type: html5
path: CF_UI
requires:
- name: CF_XSJS_api
group: destinations
properties:
forwardAuthToken: true
name: CF_XSJS_api
url: '~{url}'
- name: CF_uaa
parameters:
memory: 300MB
- name: CF_XSJS
type: nodejs
path: CF_XSJS
properties:
SAP_JWT_TRUST_ACL: '[{"clientid":"*","identityzone":"*"}]'
requires:
- name: DB
- name: hdi
- name: CF_uaa
provides:
- name: CF_XSJS_api
properties:
url: '${default-url}'
parameters:
memory: 300MB
- name: DB
type: hdb
path: DB
requires:
- name: cross-container-service-1
group: SERVICE_REPLACEMENTS
properties:
key: ServiceName_1
service: '~{the-service-name}'
resources:
- name: hdi
type: com.sap.xs.hdi-container
parameters:
config:
schema: CF_CLOUD
properties:
hdi-container-name: '${service-name}'
- name: CF_uaa
type: org.cloudfoundry.existing-service
parameters:
path: xs-security.json
service: xsuaa
service-plan: application
- name: cross-container-service-1
type: org.cloudfoundry.existing-service
parameters:
service-name: hdi
properties:
the-service-name: '${service-name}'
the .xsjs file I am trying to call post deployment:
try{
var conn = $.hdb.getConnection();
var query = 'Select * from "XXX"."CORE::USER"';
var results = conn.executeQuery(query);
conn.close();
$.response.contentType = "text/json";
$.response.setBody(results);
$.response.status = $.net.http.OK;
}
catch(e){
$.response.setBody(e);
console.log("error"+e);
}
As a solution I tried to add IDP certificate and created SAML auth in DB as mentioned here but it is still giving the same error.
Note: I am getting the expected out put when the xsuaa is disabled i.e, by keeping anonymous : true in server.js file.
using #XSJS #SAP BTP #SAP HANA CLOUD
Thanks in advance.
Hello Varun,
It's necessary configure JWT trust between the XSUAA and the HANA DB. See SAP Note 2470084 - XSUAA metadata for XS_APPLICATIONUSER trust creation
Best regards,
Lucas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi lucasvaccaro ,
Thanks a lot for the response.
But I see that the solution in the note dose not support HANA CLOUD
c) SAP Business Technology Platform (HANA Cloud)
The Note does not work here because the internal system uses different power admin, e.g DBADMIN instead of SYSTEM.
It would be great if you can help me here.
Thanks
User | Count |
---|---|
87 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.