Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Azure "JsonWebTokenError: invalid algorithm"

未关闭
#820 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
需要澄清
活跃度
停滞
技术栈
azure, javascript, node.js

调研方向

从包含 jwt.verify 的后端 API 路径开始,并将其在 Azure Static Web Apps 中的部署行为与本地模拟器进行比较。检查已部署的令牌、Microsoft identity jwks_uri 返回的证书以及配置的 RS256 算法;当确定 Azure-only invalid-algorithm 错误的原因,并且验证能够正常工作或该限制已被记录时,issue 即完成。

由索引模型根据 Issue 内容生成。

描述

Description

Only occurs when deployed to Azure cloud, local Azure Static Web Apps emulator is all ok.

Azure Static Web App (SWA) with integrated API. One of the step at backend API is to validate the Bearer Token with public key submitted in request headers:

const jwt = require("jsonwebtoken");  // v 8.5.1
async function getMSPublicKey(misc)   // misc contains kid and tenantId, confirmed in F12 request header
{
    var vurl = "https://login.microsoftonline.com/" + misc.tenantId + "/v2.0/.well-known/openid-configuration";
    const x1 = await fetch(vurl);
    const x2 = await x1.json();
    const x3 = await fetch(x2.jwks_uri);
    const k = await x3.json();
    return pkey = k.keys.find( k => k.kid === misc.kid).x5c[0];  // public key in the entry matching kid
}

var vmisc = JSON.parse(ac.req.headers["misc"]);
var publickey = "-----BEGIN CERTIFICATE-----\n" + await getMSPublicKey(vmisc) + "\n-----END CERTIFICATE-----";

// next line is reported in AppTraces, Message = JsonWebTokenError: invalid algorithm
var payload = jwt.verify(theToken, publickey, { algorithms: ['RS256'] });
// theToken is validated ok at jwt.io
Environment

Azure Static Web Application

  • jsonwebtoken: v 8.5.1
  • azurefunctions: 3.5.2.0, node v 14.16.0
  • VSC Version: 1.63.1 (system setup)
    Commit: fe719cd3e5825bf14e14182fddeb88ee8daf044f
    Date: 2021-12-14T02:13:54.292Z
    Electron: 13.5.2
    Chromium: 91.0.4472.164
    Node.js: 14.16.0
    V8: 9.1.269.39-electron.0
    OS: Windows_NT x64 10.0.19044
主要语言
JavaScript
星标
18.2k
派生
1.3k
PR 合并指标
30 天内没有已合并 PR

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

auth0/node-jsonwebtoken 的其他 Issue

查看 auth0/node-jsonwebtoken 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。