【问题标题】:express TSOA + passportexpress TSOA + passport
【发布时间】:2022-12-01 20:18:56
【问题描述】:

I'm trying to migrate a custom based controller API based on express to TSOA framework. I was usingpassportto handle authentication before.

How can I use it with TSOA? It seems to be ignored.

【问题讨论】:

    标签: express passport.js tsoa


    【解决方案1】:

    I think that you need just to add app.use(passport.authenticate('jwt')); above RegisterRoutes(app); in your (propbaly) server.ts file.

    Like this:

    // ...
    // passport.use('jwt',new JWTStrategy({<your_data_here>}));
    // passport.initialize();
    app.use(passport.authenticate('jwt'));
    RegisterRoutes(app);
    // ...
    // const httpServer = createServer(app);
    // httpServer.listen(82811, () => {
    //   console.log(`Server is running at http://localhost:82811`);
    // });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-08-13
      • 2022-08-22
      • 2013-03-11
      • 1970-01-01
      • 2013-02-07
      • 2020-01-14
      • 2017-04-18
      • 2015-12-07
      相关资源
      最近更新 更多