I am new to server-side application development in SAP Cloud Platform and Nodejs. I have configured SAP identity authentication service as an identity provider with the sub-account in SAP Cloud Platform cockpit. My MTA(UI5+Nodejs) application deployed in cloud foundry sub-account uses UAA service for authentication. Now when I access the application it redirects me to IDP for authentication. After successful authentication, I can see my application home page. I want to identify the user who has logged into the application. The user details are passed as assertion attributes from IDP in SAML response. I can see the user details like id, name in SAML response in chrome developer tools. I am struggling to read the response to find the user id. I am using Nodejs for server-side and SAP UI5 for the front end. As I am new to Nodejs looking some pointers/help to achieve this.
If I understood you correctly, you are trying to obtain the logged in user details from the node.js server (which I assume, is bound to an XSUAA service)
You need to validate the JWT token using @sap/xssec
and passport
to obtain the user details. It can be accessed in your express.js route using
req.user.id //Get the current user ID
req.authInfo //Can be used to check scope authorizations etc.
For instance:
...
app.get('/', function (req, res, next) {
res.send('Logged-In user: ' + req.user.id);
});
...
For implementation, refer this page