简体   繁体   中英

oAuth ASP.NET Membership Provider

Are there any recommended resources for implementing a custom membership provider that uses oAuth? The goal would be to have users to log into my ASP.NET MVC application using their existing oAuth credentials. After the user is authenticated, I'd then like to leverage the built-in ASP.NET authorization features.

Thanks.

I'm not sure what you're looking for is OAuth.

OAuth is for delegating authorization, through the use of tokens. Depending on what you're doing you have two scenarios either:

  1. Your application wants to use some of the users data, hosted by a provider (say twitter or google). In which case your application would be a consumer - in short, the user would need to log-in and agree to authorizing your application to have access to the their data on the provider, and you would be given an access token which can be used to gain access to those protected resources.
  2. Alternatively, you have an application, with users who have log-ins etc. And you want to provide (ie you're the provider) access to some restricted information of your users to 3rd party applications (consumers) without exposing your users credentials to those services.

For more info on OAuth - check out the OAuth.Net website . There are currently 3 implementations of OAuth available for .Net.

Because of the way OAuth works, I can't really imagine how you could have an "OAuth" membership provider - It's really intended for securing API's, and often the goal is to delegate authorization at a more granular level ie giving a consumer application access to just a users address book data, without letting them access email archives, their calendar etc. - which doesn't fit well with a membership / role based security model.

I'm guessing what you're really looking for is OpenId ie the way you authenticate yourself with Stackoverflow itself. I would suggest reading the Stackoverflow OpenId case study here and probably the best OpenId implementation for .Net is currently part of DotNetOpenAuth project (this was formally called DotNetOpenId, the google code site for the project is here ).

I think you might be looking for DotNetOpenAuth . I haven't used it, so I can't tell you for sure if it includes a membership provider, but I would expect that it does. If not, it's open source, so should help you with what you're trying to do anyway.

你应该看看https://github.com/rustd/ASPNETTemplates ,其中包含asp.net的默认项目模板,它演示了使用OAUth登录然后扩展通用提供程序(webforms模板,但你可以为mvc做同样的事情)做角色等

Libraries have come the long way since you posted this question... I've started using this library for Oauth - it already has implemented Facebook, Twitter, PayPal and Google+ integration:

OAuth2 Social Logins - Facebook, Google, Twitter, PayPal - ASP.NET MVC C# open source library

Also, if backwards compatibility is not issue for you, Microsoft has started supporting popular OAuth providers... see this article:

Microsoft OAuth2 OWIN/Katana integration with Facebook and Google+

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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