简体   繁体   English

在ASP.NET中为OAuth2创建重定向URI

[英]Creating Redirect URI for OAuth2 in ASP.NET

I have Asp.Net MVC application and Xamarin.Forms mobile application with Azure Mobile App as back end. 我有Asp.Net MVC应用程序和Xamarin.Forms移动应用程序与Azure移动应用程序作为后端。 All will be hosted in Azure cloud. 所有内容都将托管在Azure云中。 I need to integrate Google, Microsoft and Azure AD authentication into it. 我需要将Google,Microsoft和Azure AD身份验证集成到其中。

I came across many tutorials/blogs on how to do this, but none on how to create my own redirect URI. 我遇到了很多有关如何执行此操作的教程/博客,但没有提到如何创建自己的重定向URI。

I would like to create one universal redirect URI for each of the authentication provide and host it in cloud. 我想为每个身份验证提供一个通用重定向URI,并在云端托管它。 Basically it should process the token, and I would like to retrieve basic user properties like user ID and name to be returned back to the calling app - in my case either the MVC or Xamarin mobile app. 基本上它应该处理令牌,我想检索基本的用户属性,如用户ID和名称,以返回到调用应用程序 - 在我的情况下,MVC或Xamarin移动应用程序。

Appreciate any sample project on this. 欣赏任何关于此的示例项目。

I think following two urls should be able to give you good idea about how to use oauth in azure mobile: 我认为以下两个网址应该能够让你很好地了解如何在天蓝色手机中使用oauth:

http://www.strathweb.com/2014/02/running-owin-pipeline-new-net-azure-mobile-services/ http://www.strathweb.com/2014/02/running-owin-pipeline-new-net-azure-mobile-services/

http://blog.nankov.com/azure-mobile-services-configuring-the-owin-pipeline/ http://blog.nankov.com/azure-mobile-services-configuring-the-owin-pipeline/

As per oauth itself. 按照oauth本身。 The you will need to understand (if you havent already) different oauth flow types and decide which one best suits your scenario. 您将需要了解(如果您还没有)不同的oauth流类型,并确定哪一种最适合您的方案。

https://tools.ietf.org/html/rfc6749 https://tools.ietf.org/html/rfc6749

For eg if you are using pure javascript client then implicit grant will be the best option in my view. 例如,如果您使用纯javascript客户端,那么隐式授权将是我视图中的最佳选项。

If you look at the implicit grant flow (for eg) it uses redirect uri. 如果你看一下隐式授权流程(例如)它使用重定向uri。 So When client makes a request , it uses a predefined url (given by the auth server to the client before hand). 因此,当客户端发出请求时,它会使用预定义的URL(由auth服务器提供给客户端)。 The server look at the url (and the client_id) and if it matches then it sends the response back (with a token) to that url only. 服务器查看url(和client_id),如果匹配,则将响应(带有令牌)发送回该URL。

The url is location at the client's app would be something like https://client.com/someuniquelocation/ (for eg) 网址是客户端应用程序的位置,如https://client.com/someuniquelocation/ (例如)

Hope this helps. 希望这可以帮助。

Edit: 编辑:

Have a look at the following: 看看以下内容:

Redirect to ReturnUrl after successful cookie authentication in Owin, Katana & Nancy 在Owin,Katana和Nancy成功进行cookie身份验证后,重定向到ReturnUrl

http://xabikos.com/web%20application/interception/middleware/2015/01/26/asp.net---create-an-owin-middleware-to-trigger-a-permanent-redirect.html http://xabikos.com/web%20application/interception/middleware/2015/01/26/asp.net---create-an-owin-middleware-to-trigger-a-permanent-redirect.html

https://msdn.microsoft.com/en-us/library/microsoft.owin.owinresponse.redirect(v=vs.113).aspx https://msdn.microsoft.com/en-us/library/microsoft.owin.owinresponse.redirect(v=vs.113).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM