Passport.js策略可以在身份验证调用中支持其他选项:
passport.authenticate('azuread-openidconnect',{
// Default passport options
failWithError: true,successReturnToOrRedirect: '/',// Custom option supported by the azure-ad plugin
// Type error - 'tenantIdOrName' does not exist in type 'AuthenticateOptions'
tenantIdOrName: 'common',});
使用自定义策略支持的选项,例如上面的tenantIdOrName
会导致打字错误,因为它不是护照的AuthenticateOptions
接口found here的一部分,并在{{ 1}}签名here
我尝试了一些没有成功的事情
- 模块扩充,即
authenticate
似乎会覆盖模块的类型,而不是扩展它们(我扩展名中未包含的所有内容都视为未键入) - 合并接口,即
declare module 'passport' {...}
,这似乎对declare namespace passport { interface AuthenticateOptions { ...new properties }}
方法签名没有影响。
在没有类型转换的情况下,如何在authenticate
调用中支持其他属性?