Azure의 App Service에서 기본 인증 구성

Azure의 App Service에서 기본 인증 구성

여러 가지 이유로 Azure's App Service정적 파일을 제공하는 데 사용하고 있습니다. 나는 Http Basic Authentication내 목적에 충분한 이 액세스 권한을 확보하고 싶습니다 . 어떻게 해야 합니까? 업로드를 시도했지만 .htpasswd작동하지 않는 것 같습니다.

저는 ASP.NET을 사용하지 않으므로 코드에서 이를 수행할 방법이 없습니다. Azure 포털의 App Service -> 인증/권한 부여 아래에 Google, Facebook, Twitter 로그인과 같은 옵션이 표시되지만 이는 저에게 엄청난 오버헤드입니다.

답변1

현재는 불가능합니다. Azure 웹앱은 이를 지원하지 않습니다.

이것을 확인할 수 있습니다피드백.

답변2

다음의 일부 설정을 사용하여 Azure Web Apps에 대한 기본 인증을 활성화할 수 있습니다.applicationHost.xdt. 웹앱을 시작할 때 이 파일의 일부 모듈을 로드할 수 있습니다.

단계:

  • Azure Portal에서 WebApp으로 이동합니다.
  • 왼쪽 메뉴에서 헤더를 검색하세요.개발 도구선택고급 도구(쿠두)
  • 사용디버그 콘솔 > CMD도구를 사용하여 WebApp 디렉터리로 이동합니다.\홈\사이트
  • 다음 이름의 파일을 만듭니다.applicationHost.xdt
  • 다음을 붙여넣으세요.
<?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>
  • 기본 인증을 원하는 대로 변경합니다(예: 기본값: 사용자:비밀번호).
  • web.config 재작성 규칙에 이 규칙이 포함되어 있지 않은지 확인하세요. <clear />이렇게 하면 applicationHost.xdt 파일에서 효과가 제거됩니다.
  • 파일을 저장하고 WebApp을 중지하고 시작합니다(간단한재시작~ 할 것이다~ 아니다충분하다)

노트:

  • 이것이 Linux 기반 WebApp에서 작동하는지 확실하지 않습니다.
  • FTP를 사용하여 배포 파이프라인에 이 단계를 추가할 수 있습니다.
  • 업데이트:보조 웹 앱 슬롯에서 applicationHost.xdt를 사용하는 동안 문제가 발견되었습니다. 기본 슬롯만 작동하는 것 같습니다.

답변3

관련 정보