Azure Static Web Apps는 /.auth
system 폴더를 사용하여 권한 부여 관련 API에 대한 액세스를 제공합니다. /.auth
폴더 아래의 경로를 최종 사용자에게 직접 노출하는 대신, 친숙한 URL에 대한 라우팅 규칙을 만듭니다.
공급자별 경로를 찾으려면 다음 표를 사용합니다.
권한 부여 공급자 |
로그인 경로 |
Microsoft Entra ID |
/.auth/login/aad |
GitHub |
/.auth/login/github |
예를 들어 GitHub로 로그인하려면 다음 링크와 비슷한 항목을 포함할 수 있습니다.
<a href="/.auth/login/github">Login</a>
둘 이상의 공급자를 지원하도록 선택한 경우에는 웹 사이트의 각 공급자별 링크를 노출합니다.
경로 규칙을 사용하여 기본 공급자를 /login과 같은 친숙한 경로에 매핑합니다.
{
"route": "/login",
"redirect": "/.auth/login/github"
}
로그인 후 리디렉션 설정
다음 예제와 같이 post_login_redirect_uri
쿼리 문자열 매개 변수에 정규화된 URL을 제공하여 로그인한 후 특정 페이지로 사용자를 반환합니다.
<a href="/.auth/login/github?post_login_redirect_uri=https://zealous-water.azurestaticapps.net/success">Login</a>
You can also redirect unauthenticated users back to the referring page after they sign in. To configure this behavior, create a response override rule that sets post_login_redirect_uri
to .referrer
, like in the following example.
{
"responseOverrides": {
"401": {
"redirect": "/.auth/login/github?post_login_redirect_uri=.referrer",
"statusCode": 302
}
}
}