0

我正在使用访问管理 (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”,我想打开“<a href="http://www.example.com:8080/openam/ XUI/#login/" rel="nofollow noreferrer">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;

                });
}
4

1 回答 1

1

你需要使用

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

代替

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

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

于 2019-06-10T06:43:51.787 回答