on 03-15-2020 9:48 PM
Hello all,
following what ttrapp and dhem were discussing here 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.
I "almost" got there, but I am now stuck in an issue which I really cannot resolve.
I created a simple repository sapcloudsdk-nestjs-xsuaa to replicate the issue, but here's briefly what I did:
Generate a new "auth" module, the custom strategy class and a custom guard to protect endpoints:
nest generate guard auth/xsuaa.guard
The setup compiles and the application starts. Assuming that you are using default ports, calling http://localhost:5000/yourendpoint lands to the XSUAA login page.
Do the login and:
[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 (<anonymous>)
at /Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:76:83
at XsuaaGuard.<anonymous> (/Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:48:36)
at Generator.next (<anonymous>)
at /Users/stevebob/Desktop/SAP/CLOUD SDK/xsuua-test/node_modules/@nestjs/passport/dist/auth.guard.js:20:71
at new Promise (<anonymous>)
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)
If anyone has an idea, I'll be happy to contribute - and learn 🙂
Thanks a lot,
Roberto.
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.