<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212064#M4570190</link>
    <description>&lt;P&gt;Hi Roberto,&lt;/P&gt;&lt;P&gt;I would be interested to learn from &lt;SPAN class="mention-scrubbed"&gt;daniel.hutzel&lt;/SPAN&gt; and  &lt;SPAN class="mention-scrubbed"&gt;henning.heitkoetter&lt;/SPAN&gt; about the reasons why SAP Cloud Application Programming Model uses just plain Express and SAP Cloud SDK adds NestJS to the game. Wouldn't it be an option for you to stick with CAP to provide your service including authorizations and Cloud SDK for the backend calls?&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;Gregor&lt;/P&gt;</description>
    <pubDate>Mon, 16 Mar 2020 06:49:13 GMT</pubDate>
    <dc:creator>gregorw</dc:creator>
    <dc:date>2020-03-16T06:49:13Z</dc:date>
    <item>
      <title>SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaq-p/12212063</link>
      <description>&lt;P&gt;Hello all,&lt;BR /&gt;following what &lt;SPAN class="mention-scrubbed"&gt;ttrapp&lt;/SPAN&gt; and &lt;SPAN class="mention-scrubbed"&gt;dhem&lt;/SPAN&gt; were discussing &lt;A href="https://answers.sap.com/questions/12985186/-8.html"&gt;here&lt;/A&gt; I did some research about how to (within my best effort and skills) integrate the usage of JWTStrategy from xssec library into the Passport implementation of NestJS, which is what we get when initializing a new project using the Sap Cloud SDK CLI.&lt;/P&gt;
  &lt;P&gt;I "almost" got there, but I am now stuck in an issue which I really cannot resolve.&lt;/P&gt;
  &lt;P&gt;I created a simple repository &lt;A href="https://github.com/robypag/sapcloudsdk-nestjs-xsuaa"&gt;sapcloudsdk-nestjs-xsuaa&lt;/A&gt; to replicate the issue, but here's briefly what I did:&lt;/P&gt;
  &lt;OL&gt;
   &lt;LI&gt;Prepare XSUAA instance and Destination instance on CF&lt;/LI&gt;
   &lt;LI&gt;Add the approuter to the project (using CLI's add approuter command)&lt;/LI&gt;
   &lt;LI&gt;&lt;STRONG&gt;Properly configure default-env.json files, both in the approuter folder and in the root folder&lt;/STRONG&gt; for local testing&lt;/LI&gt;
   &lt;LI&gt;Install necessary dependencies: @nestjs/passport passport passport-jwt @sap/xssec @sap/xsenv&lt;/LI&gt;
  &lt;/OL&gt;
  &lt;P&gt;Generate a new "auth" module, the custom strategy class and a custom guard to protect endpoints:&lt;/P&gt;
  &lt;OL&gt;
   &lt;LI&gt;nest generate module auth/auth&lt;BR /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1790532-auth-module.png" /&gt;&lt;BR /&gt;&lt;/LI&gt;
   &lt;LI&gt;nest generate class auth/xsuaa.strategy&lt;BR /&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1790531-xsuaa-strategy.png" /&gt;&lt;/LI&gt;
   &lt;LI&gt;&lt;P&gt;nest generate guard auth/xsuaa.guard&lt;/P&gt;&lt;P&gt;&lt;IMG class="migrated-image" src="https://community.sap.com/legacyfs/online/storage/attachments/storage/7/attachments/1790533-xsuaa-guard.png" /&gt;&lt;/P&gt;&lt;/LI&gt;
  &lt;/OL&gt;
  &lt;P&gt;The setup compiles and the application starts. Assuming that you are using default ports, calling &lt;A href="http://localhost:5000/yourendpoint" target="test_blank"&gt;http://localhost:5000/yourendpoint&lt;/A&gt; lands to the XSUAA login page. &lt;/P&gt;
  &lt;P&gt;Do the login and:&lt;/P&gt;
  &lt;PRE&gt;&lt;CODE&gt;[Nest] 17174   - 2020-03-15 21:48:43   [ExceptionsHandler] this._secretOrKeyProvider is not a function +15597ms
TypeError: this._secretOrKeyProvider is not a function
    at XsuaaStrategy.JwtStrategy.authenticate (/Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/passport-jwt/lib/strategy.js:99:10)
    at attempt (/Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/passport/lib/middleware/authenticate.js:366:16)
    at authenticate (/Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/passport/lib/middleware/authenticate.js:367:7)
    at Promise (/Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:84:3)
    at new Promise (&amp;lt;anonymous&amp;gt;)
    at /Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:76:83
    at XsuaaGuard.&amp;lt;anonymous&amp;gt; (/Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:48:36)
    at Generator.next (&amp;lt;anonymous&amp;gt;)
    at /Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:20:71
    at new Promise (&amp;lt;anonymous&amp;gt;)&lt;/CODE&gt;&lt;/PRE&gt;
  &lt;P&gt;I think it is related on how the strategy is being configured: the "secretOrKeyProvider" parameter expect a callback function (and not a new JWTStrategy instance)&lt;/P&gt;
  &lt;P&gt;If anyone has an idea, I'll be happy to contribute - and learn &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
  &lt;P&gt;Thanks a lot,&lt;/P&gt;
  &lt;P&gt;Roberto.&lt;/P&gt;</description>
      <pubDate>Sun, 15 Mar 2020 21:48:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaq-p/12212063</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-03-15T21:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212064#M4570190</link>
      <description>&lt;P&gt;Hi Roberto,&lt;/P&gt;&lt;P&gt;I would be interested to learn from &lt;SPAN class="mention-scrubbed"&gt;daniel.hutzel&lt;/SPAN&gt; and  &lt;SPAN class="mention-scrubbed"&gt;henning.heitkoetter&lt;/SPAN&gt; about the reasons why SAP Cloud Application Programming Model uses just plain Express and SAP Cloud SDK adds NestJS to the game. Wouldn't it be an option for you to stick with CAP to provide your service including authorizations and Cloud SDK for the backend calls?&lt;/P&gt;&lt;P&gt;Best regards&lt;BR /&gt;Gregor&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 06:49:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212064#M4570190</guid>
      <dc:creator>gregorw</dc:creator>
      <dc:date>2020-03-16T06:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212065#M4570191</link>
      <description>&lt;P&gt;Hello Gregor,&lt;/P&gt;&lt;P&gt;Yes, I could stick to CAP, but my use case fits perfectly with the SDK purpose (and I really like the NestJS approach), so I wanted to learn &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;There’s a way to make authentication and authorization work by using plain ExpressJS middleware, let’s say my question was more related on how to completely embrace Nest and - most of all - share the idea and my findings!&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;Roberto&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 09:24:43 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212065#M4570191</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-03-16T09:24:43Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212066#M4570192</link>
      <description>&lt;P&gt;Hi Roberto, hi Gregor,&lt;/P&gt;&lt;P&gt;I have not used the xssec library myself before, therefore I cannot definitively comment on this issue. Before investigating the issue, let me start with a question: What exactly are you trying to achieve? For which reason are you trying to integrate xssec? If it's only about protecting your backend from unauthorized access, you may find simpler solutions. But given that you've also mentioned local development, I have a feeling your requirements are a little more specific than that.&lt;/P&gt;&lt;P&gt; @Gregor: Fair question. When you generate a new project using the "@sap-cloud-sdk/cli", we currently generate a project based on Nest.js. When deciding what lib/framework to use there, I did initially have the same concerns you seem to have. Express does seem to be the lowest common denominator that probably won't offend anyone. However, Nest.js does use Express under the hood by default (or, to phrase it from a different perspective, Nest.js is just a wrapper over Express). That means that anything that you can do in Express (e.g. use CAP) you can also do in Nest.js. IIRC we did even try using CAP in Nest before switching to it.&lt;BR /&gt;Apart from that, we as SAP Cloud SDK do not officially endorse Nest.js as the definitive technology for building web applications (we might need to make this more explicit in our docs, to be fair). We have found that Nest offers many things out of the box that we'd need to build/integrate ourselves otherwise, but at the same time we also did not look at every aspect yet. &lt;/P&gt;&lt;P&gt;@Roberto: That being said, I'd like to second Gregor's question here: have you checked whether there's something in CAP that already solves this for you? (Or more general: have you looked at CAP in general?).&lt;/P&gt;&lt;P&gt;I will try to find out whether someone from the xssec team can chime on this issue (depending on what the actual problem turns out to be).&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 09:40:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212066#M4570192</guid>
      <dc:creator>dhem</dc:creator>
      <dc:date>2020-03-16T09:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212067#M4570193</link>
      <description>&lt;P&gt;Hello Dennis,&lt;BR /&gt;It' much more simple then that actually &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I'm working on a SuccessFactors extension app, no persistence and no OData service exposure (the UI will be developer by the customer, who doesn't know (and doesn't want to learn) OData).&lt;BR /&gt;My service will get data, do something on the fly, and give back plain json resources.&lt;/P&gt;&lt;P&gt;The SDK seemed the best option to me, the OData generator now works perfectly and with a few calls I have my service up and running.&lt;/P&gt;&lt;P&gt;Given that the SDK provides a NestJs application out of the box, I did try to learn it at my best. I've previous Angular experience, so I felt a little bit at home with Nest.&lt;/P&gt;&lt;P&gt;When it came to security, I followed the common Nest approach of Passport+Strategies and came across this problem (as already asked by others &lt;A href="https://answers.sap.com/questions/12985186/-8.html"&gt;here&lt;/A&gt;).&lt;/P&gt;&lt;P&gt;To answer you, yes I've looked into CAP and it can solve the problem and yes, using plain ExpressJs middleware works as well.&lt;BR /&gt;On the other side, I can simply switch to the Java version of the SDK and use Spring Security.&lt;/P&gt;&lt;P&gt;This is not really a requirement, I just wanted to share my findings when trying to integrate XSSec into Nest: maybe this could be useful whenever Nest becomes the de-facto standard for the SDK, or maybe not &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Thank you both for your comments!&lt;/P&gt;</description>
      <pubDate>Mon, 16 Mar 2020 09:58:23 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212067#M4570193</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-03-16T09:58:23Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212068#M4570194</link>
      <description>&lt;P&gt;Hi Roberto, thanks for the feedback! Just for my personal understanding, can you quickly elaborate on the security concept for your app? I'd guess that callers will have to provide a user token (JWT) on which you want to check scopes?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 12:32:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212068#M4570194</guid>
      <dc:creator>dhem</dc:creator>
      <dc:date>2020-03-18T12:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212069#M4570195</link>
      <description>&lt;P&gt;Hi Dennis,&lt;BR /&gt;In the end the security concept is quite simple.&lt;BR /&gt;Ideally, the application is hosted in a subaccount for which the IdP is SuccessFactors itself, so that after login, Role-Based dynamic authorization checks will be performed directly in the platform.&lt;/P&gt;&lt;P&gt;From the extension point of view, I just need to check the user scope against 3 possible values, which are the usual ESS/MSS/XSS of an HCM application.&lt;/P&gt;&lt;P&gt;Depending on the user scope, or a combination of them, the application will react accordingly (disable updates, etc..).&lt;/P&gt;&lt;P&gt;Cheers,&lt;BR /&gt;R.&lt;/P&gt;&lt;P&gt;PS: i did some more digging on the interaction between xssec and NestJS passport strategy approach, I'll be more than happy to share my findings if you think they'll be useful.&lt;/P&gt;</description>
      <pubDate>Wed, 18 Mar 2020 14:52:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212069#M4570195</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-03-18T14:52:36Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212070#M4570196</link>
      <description>&lt;P&gt;Hi Roberto, I'd be happy to take a look at your findings (and I can imagine other users will be, too)!&lt;/P&gt;</description>
      <pubDate>Mon, 30 Mar 2020 08:47:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212070#M4570196</guid>
      <dc:creator>dhem</dc:creator>
      <dc:date>2020-03-30T08:47:58Z</dc:date>
    </item>
    <item>
      <title>Re: SAP Cloud SDK for JavaScript: Error integrating XSSEC with NestJS</title>
      <link>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212071#M4570197</link>
      <description>&lt;P&gt;Hello Dennis, I'll write something down, maybe in a blog, in which I would like to share my feelings about the great experience I am having working with the SDK &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I'm closing this thread for the time being.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2020 16:32:17 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/sap-cloud-sdk-for-javascript-error-integrating-xssec-with-nestjs/qaa-p/12212071#M4570197</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2020-04-02T16:32:17Z</dc:date>
    </item>
  </channel>
</rss>

