Kim*_*ist 6 node.js express identityserver4
我正在尝试弄清楚如何使用 NodeJS 进行下面的身份服务器 4 身份验证 - 在这里超出我的舒适区。
services.AddAuthentication(IdentityServerAuthenticationDefaults
.AuthenticationScheme)
.AddIdentityServerAuthentication(
options =>
{
options.Authority = "<authority-url>";
options.ApiName = "<api-url>";
});
Run Code Online (Sandbox Code Playgroud)
我在这里的流程中遗漏了一些东西,因为 C# 实现没有提供秘密或类似的东西 - 所以令牌可能是通过身份服务器验证的?如果我没有“秘密”来验证它,我将如何使用 NodeJS 验证令牌?
我偶然发现了自省端点- 我是否朝着正确的方向前进?
我能够使用 jwks -endpoint 解决这个问题,它是验证令牌的公钥,然后我还找到了一个很好的包,我用来准备中间件:
private issuer: string = process.env.idsrv;
auth = jwt({
secret: jwksClient.expressJwtSecret({
cache: true, // see https://github.com/auth0/node-jwks-rsa#caching,
cacheMaxAge: ms('24h'),
rateLimit: true, // see https://github.com/auth0/node-jwks-rsa#rate-limiting
jwksRequestsPerMinute: 100,
jwksUri: `${this.issuer}/.well-known/jwks`
}),
// validate the audience & issuer from received token vs JWKS endpoint
audience: `${this.issuer}/resources`,
issuer: this.issuer,
algorithms: ["RS256"]
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5015 次 |
| 最近记录: |