Tom*_*ski 7 azure http-basic-authentication
由于不同的原因,我Azure's App Service
用来提供静态文件。我想确保这种访问Http Basic Authentication
足以满足我的目的。我怎样才能做到这一点?我尝试上传,.htpasswd
但似乎不起作用。
我没有使用 ASP.NET,所以没有办法在代码中做到这一点。在 Azure 的门户中,我在 App Service -> Authentication/Authorization 下看到了 Google、Facebook、Twitter 登录等选项,但这对我来说是巨大的开销。
可以使用applicationHost.xdt中的某些设置为 Azure Web Apps 启用基本身份验证。您可以在启动 Web 应用程序时加载此文件中的一些模块。
脚步:
<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<location path="%XDT_SITENAME%" xdt:Locator="Match(path)">
<system.webServer>
<rewrite xdt:Transform="InsertIfMissing">
<allowedServerVariables xdt:Transform="InsertIfMissing">
<add name="RESPONSE_WWW_AUTHENTICATE" xdt:Locator="Match(name)" xdt:Transform="InsertIfMissing" />
</allowedServerVariables>
<rules xdt:Transform="InsertIfMissing">
<rule name="BasicAuthentication" stopProcessing="true" xdt:Transform="InsertIfMissing" xdt:Locator="Match(name)">
<match url=".*" />
<conditions>
<add input="{HTTP_AUTHORIZATION}" pattern="^Basic dXNlcjpwYXNzd29yZA==" ignoreCase="false" negate="true" />
</conditions>
<action type="CustomResponse" statusCode="401" statusReason="Unauthorized" statusDescription="Unauthorized" />
<serverVariables>
<set name="RESPONSE_WWW_AUTHENTICATE" value="Basic realm=Project" />
</serverVariables>
</rule>
</rules>
</rewrite>
</system.webServer>
</location>
</configuration>
Run Code Online (Sandbox Code Playgroud)
<clear />
,因为这会消除 applicationHost.xdt 文件的影响笔记:
归档时间: |
|
查看次数: |
8261 次 |
最近记录: |