我想知道如何创建端点(GET、POST等)不需要任何身份验证就可以访问的。这是我的密码:
router.use(AuthenticationManager.ensureAuthenticated());
router.use('/', require('./index'));
router.use('/path-1', require('./path1'));
router.use('/path-2', require('./path2'));所有端点都将享受Authentication Manager。如何仅在./path1或./path2中的某些端点中禁用该身份验证管理器?
发布于 2015-08-10 08:25:12
这样做的常规方法是在AuthenticationManager中间件之前定义这些端点:
router.use('/path-1/unprotected', require('./path1'));
router.use('/path-2/unprotected', require('./path2'));
router.use(AuthenticationManager.ensureAuthenticated());这取决于path1.js和path2.js到底导出了什么,如果它按原样工作,或者您需要进行一些重写。
发布于 2015-08-10 08:48:55
可以通过以下方法对特定端点使用身份验证:
app.post('/profile', AuthenticationManager.ensureAuthenticated , userController.getUserProfile);https://stackoverflow.com/questions/31914611
复制相似问题