【问题标题】:AADSTS900561: The endpoint only accepts POST requests. Received a GET requestAADSTS900561:端点只接受 POST 请求。收到一个 GET 请求
【发布时间】:2020-12-01 08:06:31
【问题描述】:

我正在使用 asp.net 网络应用程序。我正在将此应用程序迁移到 azure 并实施 Azure AD 身份验证。 AD 身份验证和基于 Approle 的授权按预期工作。我在退出应用程序时遇到问题。

AAD-Sign-out-response-message

referred msdn-site 也尝试了这些设置,但我仍然遇到同样的问题。

需要帮助解决这个问题!!谢谢!!

我在帐户控制器中的注销方法有以下内容

public void SignOut()
    {

        HttpContext.GetOwinContext()
        .Authentication

        .SignOut(CookieAuthenticationDefaults.AuthenticationType);

        HttpContext.GetOwinContext().Authentication.SignOut(
                 CookieAuthenticationDefaults.AuthenticationType, OpenIdConnectAuthenticationDefaults.AuthenticationType);
 
    }

Startup.cs 配置如下

public void ConfigureAuth(IAppBuilder app)
    {


        app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);


        app.UseCookieAuthentication(new CookieAuthenticationOptions());

        app.UseOpenIdConnectAuthentication(
            new OpenIdConnectAuthenticationOptions
            {
                ClientId = clientId,
                Authority = Authority,
                PostLogoutRedirectUri = redirectUri,
                RedirectUri = redirectUri,
                TokenValidationParameters = new TokenValidationParameters
                {
                    ValidateIssuer = true,
                    NameClaimType = "upn",
                    RoleClaimType = "roles",    // The claim in the Jwt token where App roles are provided.
                },
                Notifications = new OpenIdConnectAuthenticationNotifications()
                {
                    //
                    // If there is a code in the OpenID Connect response, redeem it for an access token and refresh token, and store those away.
                    //
                    AuthorizationCodeReceived = OnAuthorizationCodeReceived,
                    AuthenticationFailed = OnAuthenticationFailed
                }

            });

        // Configure the db context, user manager and signin manager to use a single instance per request
        app.CreatePerOwinContext(ApplicationDbContext.Create);           
        

    }

带有 AD 配置详细信息的 web.config 如下

<add key="ida:ClientId" value="xxxxx-xxxx-xx-xxxx-xxxxxxx"/>
<add key="ida:Tenant" value="xxxxxx.onmicrosoft.com"/>
<add key="ida:AADInstance" value="https://login.microsoftonline.com/{0}"/>
<add key="ida:PostLogoutRedirectUri" value="https://login.microsoftonline.com/common/oauth2/v2.0/logoutsession/"/>
<add key="ida:RedirectUri" value="https://xxxxxxxx.azurewebsites.net/"/>

【问题讨论】:

  • 能否提供您的代码?
  • @JimXu:感谢您的帮助...我已经更新了代码和配置详细信息。如果您需要更多详细信息,请告诉我。

标签: c# asp.net web-applications azure-active-directory logout


【解决方案1】:

我尝试重新创建您的问题,如果您像我一样在门户中配置了 logouturl,您可以尝试删除它然后运行程序。

【讨论】:

  • 我尝试删除注销 url 并添加应用程序 url。它按预期工作。谢谢!!
  • @PMCKarur 如果我的回答对您有帮助,您可以接受它作为答案(单击答案旁边的复选标记将其从灰色切换为已填充。)。这对其他社区成员可能是有益的。谢谢。
猜你喜欢
  • 1970-01-01
  • 2018-11-13
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-10-27
  • 1970-01-01
  • 1970-01-01
  • 2014-07-24
相关资源
最近更新 更多