on 2022 May 18 11:43 AM
How to use SAP Passport for CAP model at UI level so that it is added to header of all service call.
I was following this document =SAP Passport
1, In src/index.js
const libepp = require('@sap/sapdsrpassport');
const Tools = require ('@sap/sapdsrpassport/dist/util/Tools')
const CompTypes = require ('@sap/sapdsrpassport/dist/model/ComponentTypes')
const TFlags = require ('@sap/sapdsrpassport/dist/model/TraceFlags')
let epp = new libepp.DsrPassport();
// Step 1: Create a basic DsrPassport
epp.createV3Passport(
TFlags.TraceFlags.LOW, // (NONE|LOW|MEDIUM|HIGH) Use LOW for just correlation
"DemoComponent_1", // Passport Creator ComponentName
0, // Service: 0 for "undefined"
"<dummy>", //
"action", //
11, // ActionType: 11 denotes HTTP Request
"DemoComponent_1", // Previous Component PreviousComponentName
Tools.Tools.createGUID(16), // TransactionID
" ", // In case of ABAP system Source Client, else " "
CompTypes.ComponentTypes.TRACELIB, // Corresponding Component Type (see ComponentTypes)
Tools.Tools.createGUID(16), // RootContextId
Tools.Tools.createGUID(16), // ConnectionId
1); // ConnectionCounter
// Step 2
let strEpp = epp.getPassportAsString(); // get Header Value for SAP-PASSPORT header
console.info(strEpp);
// Step 1: Create a Copy of an existing Passport as Outbound Passport
let eppCopy = new libepp.DsrPassport(); // new DsrPassport Object
eppCopy.parsePassport(strEpp); // parse header value strEpp into DsrPassport Object
// Step 2: Update relevant fields of the Outbound Passport
eppCopy.setConnectionId(Tools.Tools.createGUID(16));
eppCopy.setConnectionCount(1);
eppCopy.setPreviousComponent("DemoComponent_2");
let strHeader = "SAP-PASSPORT: " + eppCopy.getPassportAsString();
console.info(strHeader);
// Access a single SAP Passport field (e.g. TransactionId)
// Example for TransactionId
let transId = epp.getTransactionId();
console.info(transId);
// Example for ConnectionId
let connId = epp.getConnectionId()
console.info(connId);
// Example for ConnectionCounter
let connCt = epp.getConnectionCount()
console.info(connCt);
// Example for ComponentId (=== SystemId)
let compName = epp.getComponentId()
console.info(compName);
let version = epp.getVersion()
console.info(version);
let action = epp.getAction()
console.info(action)
console.info(epp.getPreviousComponentId())
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
JavaScript node.js Examples
0. Preparation
use in node.js from nexus npm
add dependency to package.json: example below
{
"name": "passport-js-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"@sap/sapdsrpassport": "http://nexus3.wdf.sap.corp:8081/nexus/repository/deploy.releases.npm/@sap/sapdsrpassport/-/sapdsrpassport-1.0.2.tgz"
}
}
npm install
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
CAP should not care about the SAP Passport. The SAP Passport X.509 Client Certificate is used for authentication on the Identity Provider. This Identity provider is called from the Approuter. When successfully authenticated the approuter can get a JWT from the UAA Service. That is used for all service calls in CAP.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
69 | |
11 | |
10 | |
10 | |
9 | |
7 | |
7 | |
7 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.