默认情况下,使用 Azure Active Directory 登录页面托管在 IIS 中的 ASP.NET Web 应用程序

标签 asp.net azure iis azure-active-directory

我有一个部署在 Azure VM 中的 ASP.NET 4.5 Web 应用程序。我已经配置了 IIS 服务器和所有内容,但没有进行身份验证。任何人都可以访问 Web 应用程序。

我想配置我的 Web 应用程序,以便每次尝试访问我的 Web 应用程序的人都会先重定向到 Microsoft Azure Active Directory 登录名。如果用户名和密码是 Azure Active Directory 的一部分,我希望它们进入 Web 应用程序,否则应该会失败。

我看过很多关于部署 Azure 应用服务的教程,看起来非常简单,但是,当您在 Azure 虚拟机中部署 Web 应用程序时,它是如何完成的?

编辑:我找到了一个完全符合我需要的教程,而且效果很好

https://github.com/Azure-Samples/active-directory-dotnet-webapp-webapi-openidconnect

但是,如何重定向到在 Web 应用程序加载之前始终要求登录?

最佳答案

为了保证在发送身份验证请求时,无论已经存在什么 session cookie,用户都必须输入凭据,OpenID Connect 将在收到 prompt=login 时采取这种方式> 请求中的参数:

 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,
                        RedirectToIdentityProvider = (context) =>
                        {
                            context.ProtocolMessage.Prompt = "login";
                            return Task.FromResult(0);
                        },
                    }

即使您之前已经登录过 azure ad,使用该参数,系统也会要求用户输入凭据。

关于默认情况下,使用 Azure Active Directory 登录页面托管在 IIS 中的 ASP.NET Web 应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45382145/

相关文章:

jquery 选择器不适用于加载了 asp :UpdatePanel 的控件

java - 如何将 JDBC azure sql 服务器连接到 Android 应用程序?

function - 状态 : 503 Service Unavailable Azure Function

azure - 使用 Azure CLI 创建新资源时的标签格式

jquery - 如何说服浏览器从缓存中加载图像而不是从服务器获取

c# - 从 https 谷歌搜索中获取谷歌搜索词

c# - 为我自己的类库创建选项类

c# - WebResource.axd 404

.net - ASP.Net 网站收到大量请求,导致 IIS 工作进程崩溃

IIS 网站的 Powershell 脚本(SMTP 中继)