无法从以下位置获取配置:“ http://www.example.com:8080/openam/.well-known/openid-configuration”

时间:2019-06-09 12:08:00

标签: asp.net-mvc .net-core asp.net-core-2.1 openam forgerock

我正在使用访问管理(OPENAM)6.5版和ASP.NET Core 2.1。 我创建了简单的mvc Web应用程序。我添加了“ google”,“ facebook”外部登录以及“ openam”作为外部登录。 但是我遇到了以下错误。

HttpRequestException: Response status code does not indicate success: 404 ().
System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()

IOException: IDX20804: Unable to retrieve document from: 'http://www.example.com:8080/openam/.well-known/openid-configuration'.
Microsoft.IdentityModel.Protocols.HttpDocumentRetriever.GetDocumentAsync(string address, CancellationToken cancel)

InvalidOperationException: IDX20803: Unable to obtain configuration from: 'http://www.example.com:8080/openam/.well-known/openid-configuration'.
Microsoft.IdentityModel.Protocols.ConfigurationManager<T>.GetConfigurationAsync(CancellationToken cancel)

在程序网页http://localhost:44383/中,我可以单击外部登录按钮“ Openam”,我想打开“ http://www.example.com:8080/openam/XUI/#login/”登录界面。

我在做什么错? 我的代码:

public void ConfigureServices(IServiceCollection services) {
..
 services.AddAuthentication(options =>
            {
                options.DefaultAuthenticateScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultChallengeScheme = CookieAuthenticationDefaults.AuthenticationScheme;
                options.DefaultSignInScheme = CookieAuthenticationDefaults.AuthenticationScheme;
            })
                .AddFacebook(options =>
                {
                    options.AppId = "23433128857274851";
                    options.AppSecret = "dc70a87e2ab33a4fcb6845b55561ac9";
                })
                .AddGoogle(options =>
                {
                    options.ClientId = "598762028893-hsl3b3bldhoscvi2r8t4tuquf23dn6g.apps.googleusercontent.com";
                    options.ClientSecret = "3PtzMqjesmCm2TizQpNmDi9";

                })

                .AddCookie(options =>
                {
                    //options.LoginPath = "/auth/signin";
                    options.LoginPath = new PathString("/ Account / Login");
                    options.LogoutPath = new PathString("/ Account / Logout");
                })

                .AddOpenIdConnect("oidc", options => {

                    options.Authority = "http://www.example.com:8080/openam";
                    options.MetadataAddress = "http://www.example.com:8080/openam/.well-known/openid-configuration";
                    options.ClientId = "ASPNETClient";
                    options.ClientSecret = "Pa$$w0rd";
                    options.GetClaimsFromUserInfoEndpoint = true;
                    options.ResponseType = "id_token";
                    options.Scope.Clear();
                    options.Scope.Add("openid");
                    options.RequireHttpsMetadata = false;

                });
}

1 个答案:

答案 0 :(得分:1)

您需要使用

coll = Request.Headers

代替

http://www.example.com:8080/openam/oauth2/.well-known/openid-configuration

请参阅https://backstage.forgerock.com/docs/am/6.5/oidc1-guide/#configure-openid-connect-discovery