在.Net Core中共享默认的OWIN令牌 [英] Share default OWIN tokens in .Net core

查看:251
本文介绍了在.Net Core中共享默认的OWIN令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有基于.NET 4.5.1构建的授权服务器,并且使用Microsoft.Owin.Security.OAuth版本= 3.0.0 http://prntscr.com/hvwhl4 通过machinkey保护的令牌(默认为OAuthAuthorizationServerOptions.AccessTokenFormat).我在.NET 4.5.1上也有许多应用程序使用者(资源服务器),它们可以验证这些令牌 http://prntscr.com/hvwwdu http://prntscr.com/hvwiwr .所有这些应用程序在web.config中都具有相同的machinkey

I have Authorization server which built on .NET 4.5.1 and use Microsoft.Owin.Security.OAuth Version=3.0.0 http://prntscr.com/hvwhl4 Tokens protected via machinkey (OAuthAuthorizationServerOptions.AccessTokenFormat is default). I also have many application-consumers(resource servers) on .NET 4.5.1 which validate these tokens http://prntscr.com/hvwwdu http://prntscr.com/hvwiwr. All these applications have the same machinkey in web.config

现在,我尝试构建.net core 2.0应用程序,并且需要使用来自Auth服务器的相同令牌(.net 4.5.1 owin 3.0.0).如何验证和读取.net core 2.0中Microsoft.Owin.Security.OAuth(3.0.0)令牌的声明?

Now I try to build .net core 2.0 application and I need to use the same tokens from my Auth server(.net 4.5.1 owin 3.0.0). How can I validate and read claims from Microsoft.Owin.Security.OAuth(3.0.0) tokens in .net core 2.0?

一个注意事项:我无法更改Auth服务器并在Auth服务器中定义DataProtector.因此,我需要找到一种方法,如何使用现有的机器密钥在.net核心中解码" OWIN令牌.

One note: I can't change my Auth server and define DataProtector in Auth server. So I need to find a way how to "decode" OWIN tokens in .net core using existing machine key.

更新:所以我在github https://github.com/aspnet/Security/issues/1592

UPDATE: So I've opened issue on github https://github.com/aspnet/Security/issues/1592

现在关闭了,答案是:关闭,因为没有计划来支持此操作.您可以使用第三方令牌服务器(例如Identity Server)来发行在两个系统上都可以使用的令牌.或者,您可以编写自定义标签ASP.NET Core的代码来处理OWIN/Katana样式的令牌."

Now It is closed and the answer was: "Closing because there are no plans to support this. You can use a 3rd party token server such as Identity Server to issue tokens that work with both systems. Or, you can write custom code for ASP.NET Core to handle the OWIN/Katana-style tokens."

我找到了一种解决方案.我在Auth服务器中使用Autofac.Integration.Owin包和OAuthAuthorizationServerMiddleware在运行时定义我从哪个资源服务器收到请求,然后定义我需要以哪种格式返回令牌.

I find a kind of solution. I use Autofac.Integration.Owin package and OAuthAuthorizationServerMiddleware in my Auth server to define in run time from which resource server I got the request and then define in which format I need to return token.

请在Auth服务器的Autofac配置中找到以下代码:

Please find below a piece of code from Autofac config in Auth server:

推荐答案

我使用此软件包

这篇关于在.Net Core中共享默认的OWIN令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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