我正在尝试使用ASP.Net Core2通过Steam API对用户进行身份验证和登录。
我的成功是有限的。我认为我需要以下参数:
providerURL: 'http://steamcommunity.com/openid',
stateless: true,
// How the OpenID provider should return the client to us
returnURL: 'http://localhost:4000/auth/openid/return',
realm: 'http://localhost:4000/',
我正在尝试通过AddOpenIDConnect机制添加身份验证。
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
services.AddIdentity<ApplicationUser, IdentityRole>()
.AddEntityFrameworkStores<ApplicationDbContext>()
.AddDefaultTokenProviders();
services.AddAuthentication().AddOpenIdConnect(steamOptions =>
{
steamOptions.ClientId = "<APIKEY>";
steamOptions.ClaimsIssuer = "https://steamcommunity.com/openid";
}
这不管用。显然,一定有更好的方式来调用它。
我遇到过一件值得注意的事情: Postman的GET请求返回一个XML文件:
<?xml version="1.0" encoding="UTF-8"?>
<xrds:XRDS xmlns:xrds="xri://$xrds" xmlns="xri://$xrd*($v*2.0)">
<XRD>
<Service priority="0">
<Type>http://specs.openid.net/auth/2.0/server</Type>
<URI>https://steamcommunity.com/openid/login</URI>
</Service>
</XRD>
</xrds:XRDS>
有没有办法强制services.AddAuthentication()解析XML?
发布于 2018-01-21 15:16:01
我用Kévin Chalet最近开发的AspNet.Security.OpenID.Steam library解决了这个问题。对于ASP.Net Core2,您需要使用2.0.0-rc2-final。
您所需要做的就是将services.AddAuthentication().AddSteam()添加到ConfigureServices中,如下所示(它不是其中唯一的服务):
public void ConfigureServices(IServiceCollection services)
{
services.AddAuthentication().AddSteam();
}
请注意,您将需要安装由Asp.Net Core2WebMVC模板和标识生成的其他默认服务。
https://stackoverflow.com/questions/48363328
复制相似问题