sapmentors / cap-community

SAP CAP Community
MIT License
97 stars 26 forks source link

req.user.attr with xssec v3 #95

Open the-docta opened 4 years ago

the-docta commented 4 years ago

after changing usage to @sap/xssec@v3 with cds v4, req.user.attr doesnt contain lastName, firstName, email and logonName fields any more.

Full output of "cds version" @sap/audit-logging: 3.1.1 @sap/cds: 4.1.7 @sap/cds-compiler: 1.35.0 @sap/cds-dk: 2.0.8 @sap/cds-foss: 2.0.0 @sap/cds-mtx: 1.0.17 @sap/cds-reflect: 2.12.2 @sap/cds-runtime: 2.1.7 @sap/hana-client: 2.5.105 @sap/hdi-deploy: 3.11.11 @sap/instance-manager: 2.2.0 @sap/xsenv: 3.0.0 @sap/xssec: 3.0.9 Node.js: v12.12.0

attached is a patch for cds-runtime

--- node_modules/@sap/cds-runtime/lib/common/auth/passport.js   1985-10-26 09:15:00.000000000 +0100
+++ node_modules/@sap/cds-runtime/lib/common/auth/passport.js   2020-08-27 14:09:13.000000000 +0200
@@ -122,6 +122,12 @@
       {},
       {
         get: function (_, attr) {
+          if (typeof attr === "string" && attr.length) {
+            const getter = `get${attr[0].toUpperCase()}${attr.slice(1)}`;
+            if (typeof info[getter] === "function") {
+              return info[getter](); 
+            }
+          }  
           return info.getAttribute(attr)
         }
the-docta commented 4 years ago

filed as 561086 / 2020

the-docta commented 4 years ago

(will be available with next release)