on 02-20-2020 6:52 AM
Hey,
I'm wondering if there are any examples available showing how to make use of @sap/xssec (especially the included JwtStrategy) within a Nest.JS project, since this is what you get (and want) when starting a new project with the sap-cloud-sdk CLI...
Hi Tobias,
currently we don't have any more advanced tutorials with Nest.js than our getting started series. However, Nest.js by default uses Express.js under the hood. Here's an example showing how to use the JWTStrategy with Passport (which is a middleware package for Express.js):
var express = require('express');
var passport = require('passport');
var JWTStrategy = require('@sap/xssec').JWTStrategy;
var xsenv = require('@sap/xsenv');
...
var app = express();
...
passport.use(new JWTStrategy(xsenv.getServices({uaa:{tag:'xsuaa'}}).uaa));
app.use(passport.initialize());
app.use(passport.authenticate('JWT', { session: false }));
Based on this, the Nest.js documentation on middleware should hopefully provide you with the means to integrate this into your project.
Hope that helps!
Best regards,
Dennis
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Dennis,
I am already using those express middlewares as global middlewares within my nest app, which works pretty good so far.
I just thought there might be some examples on how to wrap that into Nest.JS Guards to be more flexible. I think, I will come back to that idea when having digged a little deeper into nest...
Thanks a lot for your support!
You're welcome! If you build something that you think is worth sharing, I'd be happy to take a look at it!
User | Count |
---|---|
83 | |
10 | |
10 | |
9 | |
7 | |
6 | |
6 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.