使用identityserver4授权nodejs端点 [英] Authorizing nodejs endpoint using identityserver4

查看:361
本文介绍了使用identityserver4授权nodejs端点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,



我对如何使用identity-server4授权我的节点应用服务感到困惑,它在dotnet环境中是直截了当但有点令人困惑这里是节点。我想使用Identity-Server4来保护我的所有服务(应该与平台无关......)。



请告诉我如何在NodeJs中实现这一点..以下代码片段是用c#dotnet编写的我需要它与Node的计数器匹配吗?







问候



我有什么试过:



services.AddMvcCore()

.AddAuthorization()

.AddJsonFormatters( );



services.AddAuthentication(Bearer)

.AddIdentityServerAuthentication(options => {

options.Authority =http:// localhost:5000 /;

options.RequireHttpsMetadata = false;

options.ApiName =api1;

});

Dear All,

I got confused on how to authorize my node-app service using identity-server4, it is straight forward in dotnet environment but a bit confusing here in node. I wanted to secure all my services(shouldn't matter the platforms..) using Identity-Server4.

Please clue me how to achieve this in NodeJs..the following piece of code is written in c# dotnet I need its counter match for Node?



Regards

What I have tried:

services.AddMvcCore ()
.AddAuthorization ()
.AddJsonFormatters ();

services.AddAuthentication ("Bearer")
.AddIdentityServerAuthentication (options => {
options.Authority = "http://localhost:5000/";
options.RequireHttpsMetadata = false;
options.ApiName = "api1";
});

推荐答案

这是在.NET核心中配置auth。它与身份服务器几乎没有关系。



That's configuring auth in .NET core. It has little to do with identity server.

.AddIdentityServerAuthentication (options => {
options.Authority = "http://localhost:5000/";
options.RequireHttpsMetadata = false;
options.ApiName = "api1";
});





此行正在调用IdentityServer提供的中间件。



我用Google搜索并发现这个



认证的OpenID Connect实施 - OpenID [ ^ ]


我的解决方案很简单!



我做的是,我从IdentityServer准备了一个端点令牌得到验证。

然后,我写了一个简单的nodjes库,其中nodejs服务引用并使用它来发送令牌并通过IdentityServer验证。



nodejs服务,每当请求到来时,它会检查标头并获取令牌。



通过这样做,我已经为需要的端点启用了授权保证。



问候
My solution is came out simple!

What I did is, I have prepared an endpoint from the IdentityServer whereby tokens get validated.
Then, I wrote a simple nodjes library whereby the nodejs service refers-to and uses it to send a token through and get validated by the IdentityServer.

The nodejs service, whenever a request comes, it checks the header and fetches the token.

By doing that I have enabled authorization for the endpoints that need to be secured.

Regards


这篇关于使用identityserver4授权nodejs端点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆