我最近一直在玩 ASP.NET MVC5 和新的 OWIN 身份验证中间件。
我希望我的用户使用他们的 Steam 帐户和密码登录。用户成功登录后,我只需要 Steam 帐户 ID 以进行进一步处理。 Steam 可以充当 OpenId 提供者 as stated in the documentation .
在 MVC4 中,会 implement a custom OpenIdClient .在我看来,在 MVC5 中 OpenIdClient 类已被删除,并且使用 IAppBuilder 类配置身份验证,该类提供了使用 Facebook、Google 和其他预定义提供程序登录的方法。
不幸的是,我找不到任何有关将自定义提供程序插入新身份验证系统的文档。你能给我任何说明或引用吗?
最佳答案
这是对@Buzinas 悬赏的回答。
此解决方案将使用可用的 NuGet 包 Owin Security Providers here .
转到包管理器控制台 ( Tools -> Library Package Manager -> Package Manager Console
) 并安装上述包:
Install-Package Owin.Security.Providers
在您的
App_Start\Startup.Auth.cs
添加正确的 using
陈述。对于 Steam,您想要using Owin.Security.Providers.Steam;
旁注,有多个选项可用,因此此软件包不仅适用于 Steam。
在
ConfigureAuth
方法,添加 app.UseSteamAuthentication("<<API KEY>>");
<<API_KEY>>
应替换为您从 Valve 收到的 API key
关于authentication - 在 ASP.NET MVC5 中使用 Steam 登录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19477524/