들어가며
최근 우리 서비스에서 AWS Cognito를 통해 Microsoft Entra ID (구 Azure AD) SSO 인증을 제공하던 중, 일부 고객사에서 AADSTS50011 에러가 발생했습니다. 이 에러는 redirect URI 불일치로 인해 발생하는데, 해결 과정에서 얻은 인사이트를 공유하고자 합니다.
1. AADSTS50011 에러란?
에러 메시지 분석
1
2
3
| AADSTS50011: The redirect URI 'https://example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse'
specified in the request does not match the redirect URIs configured for the application 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'.
Make sure the redirect URI sent in the request matches one added to your application in the Azure portal.
|
에러 발생 원인
graph TD
A[사용자 로그인 시도] --> B[AWS Cognito]
B --> C[Microsoft Entra ID로 리다이렉트]
C --> D{Redirect URI 검증}
D -->|일치| E[인증 성공]
D -->|불일치| F[AADSTS50011 에러]
style F fill:#f96,stroke:#333,stroke-width:2px
style E fill:#9f9,stroke:#333,stroke-width:2px
Microsoft Entra ID는 보안을 위해 사전에 등록된 redirect URI로만 인증 응답을 보냅니다. 요청된 URI가 등록된 URI와 정확히 일치하지 않으면 이 에러가 발생합니다.
2. AWS Cognito와 Microsoft Entra ID 통합 방식
SAML vs OIDC 비교
| 구분 | SAML 2.0 | OIDC (OpenID Connect) |
| Redirect URI 형식 | /saml2/idpresponse | /oauth2/idpresponse |
| 프로토콜 | XML 기반 | JSON/JWT 기반 |
| 복잡도 | 높음 | 중간 |
| 모바일 지원 | 제한적 | 우수 |
| 권장 사용 | 레거시 시스템 | 신규 구현 |
올바른 Redirect URI 설정
| 요청이 돌아가는 구간 | 등록하는 곳 | 예시 |
| Entra ID → Cognito, OIDC | Entra의 해당 앱 등록 → Authentication → Web | https://login.example.com/oauth2/idpresponse |
| Entra ID → Cognito, SAML | Entra 엔터프라이즈 앱 → SAML → Reply URL(ACS) | https://login.example.com/saml2/idpresponse |
| Cognito → 내 웹 앱 | Cognito User Pool의 App client → Allowed callback URLs | https://app.example.com/callback |
login.example.com은 실제 User Pool 도메인으로 바꾸세요. Cognito 기본 도메인과 사용자 지정 도메인 중 로그인 요청이 실제로 사용하는 주소를 기준으로 비교합니다. AWS 페더레이션 엔드포인트, Microsoft AADSTS50011 해결 문서
3. 문제 해결 단계별 가이드
Step 1: 정확한 에러 정보 수집
1
2
3
4
5
| # 브라우저 개발자 도구에서 Network 탭 확인
# 실패한 요청의 redirect_uri 파라미터 복사
# 예시:
https://your-domain.auth.region.amazoncognito.com/oauth2/idpresponse
|
Step 2: Microsoft Entra ID 설정 확인
- Azure Portal 접속
- Microsoft Entra ID → App registrations
- 오류 메시지에 나온 Application ID와 일치하는 앱 등록 선택
- Authentication에서 Web 플랫폼의 Redirect URIs 확인
Step 3: Redirect URI 추가/수정
1
2
3
4
5
6
7
8
9
| 올바른 형식:
OIDC: https://<cognito-domain>.auth.<region>.amazoncognito.com/oauth2/idpresponse
SAML: https://<cognito-domain>.auth.<region>.amazoncognito.com/saml2/idpresponse
잘못된 예시:
- http:// (HTTPS 필수)
- 마지막 슬래시 추가 (/oauth2/idpresponse/)
- 대소문자 오류 (OAuth2 X, oauth2 O)
- 포트 번호 누락 (:443 제외)
|
Step 4: AWS Cognito 설정 동기화
Entra가 Cognito로 돌려보낸 뒤 내 앱으로 돌아가는 단계가 실패할 때 이 설정을 점검합니다. Entra 화면의 AADSTS50011은 위 단계에서 Entra 쪽 Redirect URI부터 확인하세요. 저장 후 새 시크릿 창에서 로그인해 최종 앱 콜백까지 이동하는지 확인합니다.
1
2
3
4
5
6
7
8
9
10
11
12
13
| // Cognito User Pool 설정 예시
{
"CallbackURLs": [
"https://app.example.com/callback",
"http://localhost:3000/callback" // 개발 환경
],
"LogoutURLs": [
"https://app.example.com/logout",
"http://localhost:3000/logout"
],
"AllowedOAuthFlows": ["code"],
"AllowedOAuthScopes": ["openid", "email", "profile"]
}
|
4. 자주 발생하는 실수와 해결법
흔한 실수 체크리스트
| 실수 유형 | 잘못된 예 | 올바른 예 | 영향도 |
| 프로토콜 불일치 | http:// | https:// | 🔴 높음 |
| 후행 슬래시 | /idpresponse/ | /idpresponse | 🔴 높음 |
| 대소문자 | /OAuth2/ | /oauth2/ | 🔴 높음 |
| 도메인 오타 | .amazoncognito.com | .amazoncognito.com | 🔴 높음 |
| 리전 불일치 | us-east-1 | ap-northeast-1 | 🔴 높음 |
| 환경 구분 미비 | 개발/운영 미구분 | 환경별 등록 | 🟡 중간 |
디버깅 팁
1
2
3
4
5
6
7
8
9
10
| # 1. Cognito 도메인 확인
aws cognito-idp describe-user-pool-domain \
--domain your-domain-prefix \
--region ap-northeast-1
# 2. 현재 설정된 Callback URLs 확인
aws cognito-idp describe-user-pool-client \
--user-pool-id ap-northeast-1_xxxxxxxx \
--client-id xxxxxxxxxxxxxxxxxxxxxxxxx \
--region ap-northeast-1 | jq '.UserPoolClient.CallbackURLs'
|
5. 환경별 설정 관리
멀티 환경 구성
| 환경 | Entra 앱 등록에 넣는 URI | Cognito 앱 클라이언트에 넣는 URI |
| 개발 | https://dev-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse | http://localhost:3000/callback |
| 스테이징 | https://staging-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse | https://staging.example.com/callback |
| 운영 | https://prod-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse | https://app.example.com/callback |
환경별 설정 예시
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
| // config/auth.config.ts
const authConfig = {
development: {
domain: 'dev-example.auth.ap-northeast-1.amazoncognito.com',
clientId: 'dev-client-id',
redirectUri: 'http://localhost:3000/callback',
idpResponseUri: 'https://dev-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse'
},
staging: {
domain: 'staging-example.auth.ap-northeast-1.amazoncognito.com',
clientId: 'staging-client-id',
redirectUri: 'https://staging.example.com/callback',
idpResponseUri: 'https://staging-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse'
},
production: {
domain: 'prod-example.auth.ap-northeast-1.amazoncognito.com',
clientId: 'prod-client-id',
redirectUri: 'https://app.example.com/callback',
idpResponseUri: 'https://prod-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse'
}
}
export default authConfig[process.env.NODE_ENV || 'development'];
|
6. 모니터링과 에러 처리
로깅 구현
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| // utils/auth-logger.ts
export class AuthLogger {
static logRedirectError(error: any) {
if (error.error === 'AADSTS50011') {
console.error('Redirect URI Mismatch:', {
timestamp: new Date().toISOString(),
requestedUri: error.redirect_uri,
applicationId: error.application_id,
suggestion: 'Check Azure AD App Registration redirect URIs'
});
// 사용자에게 친화적인 메시지 표시
return {
userMessage: 'SSO 설정에 문제가 있습니다. 관리자에게 문의해주세요.',
adminMessage: `Azure AD에 다음 URI를 추가하세요: ${error.redirect_uri}`
};
}
}
}
|
사용자 경험 개선
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
| // components/SSOErrorHandler.tsx
import React from 'react';
const SSOErrorHandler: React.FC<{ error: string }> = ({ error }) => {
if (error.includes('AADSTS50011')) {
return (
<div className="error-container">
<h2>SSO 로그인 오류</h2>
<p>현재 SSO 설정에 문제가 있어 로그인할 수 없습니다.</p>
<details>
<summary>관리자용 정보</summary>
<pre>
에러 코드: AADSTS50011
해결 방법: Azure AD App Registration에서
Redirect URI를 확인하고 추가해주세요.
</pre>
</details>
<button onClick={() => window.location.href = '/login'}>
다른 방법으로 로그인
</button>
</div>
);
}
return <div>로그인 중 오류가 발생했습니다.</div>;
};
|
7. 베스트 프랙티스
설정 관리 자동화
두 서비스의 URI 목록을 서로 비교하면 정상 설정도 불일치로 나옵니다. 각 서비스에 필요한 값을 따로 검사하세요. 아래 예제는 AWS CLI와 Azure CLI에 조회 권한으로 로그인한 뒤 Bash에서 실행합니다. ID와 예상 URI는 자신의 환경 값으로 지정합니다.
1
2
3
4
5
6
7
8
9
10
11
| set -euo pipefail
aws cognito-idp describe-user-pool-client \
--region "$AWS_REGION" \
--user-pool-id "$USER_POOL_ID" \
--client-id "$COGNITO_CLIENT_ID" \
--query 'UserPoolClient.CallbackURLs' --output json |
jq -e --arg expected "$APP_CALLBACK_URL" 'index($expected) != null'
az ad app show --id "$ENTRA_APP_ID" --query 'web.redirectUris' --output json |
jq -e --arg expected "$COGNITO_OIDC_RETURN_URL" 'index($expected) != null'
|
예를 들어 운영 환경에서 APP_CALLBACK_URL은 https://app.example.com/callback, COGNITO_OIDC_RETURN_URL은 위 표의 운영 Cognito 주소입니다. 둘 다 true가 나오면 등록값을 찾은 것입니다. 최종 확인은 실제 로그인 테스트로 진행하세요.
문서화 템플릿
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
| ## SSO 설정 문서
### Microsoft Entra ID 설정
- Application ID: `xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx`
- Redirect URIs:
- 개발: `https://dev-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse`
- 운영: `https://prod-example.auth.ap-northeast-1.amazoncognito.com/oauth2/idpresponse`
### AWS Cognito 설정
- User Pool ID: `ap-northeast-1_xxxxxxxxx`
- App Client ID: `xxxxxxxxxxxxxxxxxxxxxxxxx`
- Domain: `prod-example`
- Allowed callback URL: `https://app.example.com/callback`
### 테스트 체크리스트
- [ ] 개발 환경 SSO 로그인
- [ ] 스테이징 환경 SSO 로그인
- [ ] 프로덕션 환경 SSO 로그인
- [ ] 에러 처리 동작 확인
|
8. 트러블슈팅 체크리스트
빠른 진단 가이드
flowchart TD
A[AADSTS50011 에러 발생] --> B{브라우저 개발자 도구<br/>Network 탭 확인}
B --> C[redirect_uri 파라미터 복사]
C --> D{Azure Portal에<br/>동일한 URI 존재?}
D -->|No| E[Azure AD에 URI 추가]
D -->|Yes| F{대소문자, 슬래시<br/>정확히 일치?}
F -->|No| G[정확한 형식으로 수정]
F -->|Yes| H{5분 대기 후<br/>재시도}
H -->|성공| I[완료]
H -->|실패| J[Cognito 설정 확인]
style A fill:#f96,stroke:#333,stroke-width:2px
style I fill:#9f9,stroke:#333,stroke-width:2px
마무리
AADSTS50011 에러는 단순해 보이지만, 정확한 문자열 매칭이 필요하기 때문에 사소한 실수로도 발생할 수 있습니다. 이 글에서 제시한 체크리스트와 자동화 방법을 활용하면 이러한 에러를 사전에 방지하고, 발생 시 빠르게 해결할 수 있습니다.
핵심 포인트
- ✅ Redirect URI는 정확히 일치해야 함 (대소문자, 슬래시 포함)
- ✅ 환경별로 별도 설정 관리 필수
- ✅ 자동화와 모니터링으로 사전 예방
SSO 통합은 초기 설정이 까다롭지만, 한 번 제대로 구성하면 사용자에게 편리한 인증 경험을 제공할 수 있습니다.
참고 자료
SSO 통합 관련 경험이나 다른 에러 해결 사례가 있으시다면 댓글로 공유해주세요!