Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在ASP.NET Core 2中为Steam配置OpenID连接?_Asp.net_Asp.net Core 2.0_Steam Web Api - Fatal编程技术网

如何在ASP.NET Core 2中为Steam配置OpenID连接?

如何在ASP.NET Core 2中为Steam配置OpenID连接?,asp.net,asp.net-core-2.0,steam-web-api,Asp.net,Asp.net Core 2.0,Steam Web Api,我正在尝试使用ASP.NETCore2通过身份验证和登录用户 我的成功有限。我想我需要以下参数: providerURL: 'http://steamcommunity.com/openid', stateless: true, // How the OpenID provider should return the client to us returnURL: 'http://localhost:4000/auth/openid/return', re

我正在尝试使用ASP.NETCore2通过身份验证和登录用户

我的成功有限。我想我需要以下参数:

    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";
        }
public void配置服务(IServiceCollection服务)
{
services.AddDbContext(选项=>
options.UseSqlServer(Configuration.GetConnectionString(“DefaultConnection”));
服务.额外性()
.AddEntityFrameworkStores()
.AddDefaultTokenProviders();
services.AddAuthentication().AddOpenIdConnect(steamOptions=>
{
steamOptions.ClientId=“”;
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>

http://specs.openid.net/auth/2.0/server
https://steamcommunity.com/openid/login
我们有什么办法可以强制services.AddAuthentication()解析XML吗?

我用最近建造的Kévin小屋解决了这个问题。您需要使用ASP.Net Core 2的2.0.0-rc2-final

您所需要做的就是将services.AddAuthentication().AddSteam()添加到ConfigureServices中,就像这样(它不是其中唯一的服务):

请注意,您将需要Asp.Net Core 2 Web MVC模板生成的其他默认服务和已安装的标识。

我用刚刚构建的Kévin小屋解决了这个问题。您需要使用Asp.Net Core 2的2.0.0-rc2-final

您所需要做的就是将services.AddAuthentication().AddSteam()添加到ConfigureServices中,就像这样(它不是其中唯一的服务):

请注意,您需要安装Asp.NETCore2WebMVC模板和Identity生成的其他默认服务

public void ConfigureServices(IServiceCollection services)
{
    services.AddAuthentication().AddSteam();
}