【发布时间】:2023-01-12 19:42:13
【问题描述】:
我正在尝试验证蔚蓝广告与我的令牌嵌套后端应用程序。我正在使用登录到 Azure AD反应前端应用程序,现在,手动从响应中获取 access_token。然后我有这个守卫嵌套:
@Injectable()
export class AzureADStrategy extends PassportStrategy(
BearerStrategy,
'azure-ad',
) {
constructor() {
super({
identityMetadata: `https://login.microsoftonline.com/${tenantID}/v2.0/.well-known/openid-configuration`,
clientID,
clientSecret,
loggingLevel: 'debug',
loggingNoPII: false
});
}
async validate(response: any) {
console.log(response);
}
}
export const AzureGuard = AuthGuard('azure-ad');
当我将它应用于某个端点时,我试图获取此 URL,例如:
curl localhost:9000/test --header 'Authorization: Bearer xyz'
但是我无法进行身份验证,并且收到此错误日志:
{"name":"AzureAD: Bearer Strategy","hostname":"<hostname>","pid":1713974,"level":30,"msg":"authentication failed due to: invalid signature","time":"2022-11-03T13:00:51.213Z","v":0}
我应该如何配置它才能使其工作?
【问题讨论】:
-
我假设您已经能够正常登录,然后将详细信息传递给 API。在验证时,这就是我所拥有的并且工作正常。
标签: node.js azure azure-active-directory nestjs passport.js