제 16b장 클라이언트, 그룹웨어 & CLI Admin: #pIdentity

메일 앱용 OAuth 2.1: Thunderbird, Outlook, 기기 및 명령줄

nextxch는 자체 OAuth 2.1 인증 서버입니다. 메일 앱은 일반 웹메일 로그인(2단계 인증 및 패스키 포함)을 통해 브라우저에서 로그인하고, 사용자가 동의 페이지에서 접근 권한을 확인하면, 앱은 수명이 짧은 액세스 토큰과 갱신되는 리프레시 토큰을 받습니다. IMAP, SMTP, POP3 및 ManageSieve는 SASL XOAUTH2 및 OAUTHBEARER(RFC 7628)를 통해 토큰을 수락하고, ActiveSync, EWS 및 MAPI는 베어러(bearer)로 수락합니다. 브라우저가 없는 기기는 디바이스 코드 흐름(RFC 8628)을 사용합니다. Entra ID 또는 Keycloak의 액세스 토큰도 허용될 수 있습니다. 모든 권한 부여 내역은 사용자 및 관리자에게 표시되며 즉시 취소할 수 있습니다.

운영 팁 및 아키텍처 참고 사항

"프로토콜별 OAuth / Kerberos 전용" 설정을 통해(관리자 > ID 소스) 단일 프로토콜 및 도메인에 대해 비밀번호 및 앱 비밀번호를 비활성화할 수 있습니다(예: OAuth 전용 IMAP 및 SMTP). 소스가 없는 로컬 서버 관리자는 긴급 액세스(break-glass)를 위해 예외로 유지됩니다.

명령줄: 디바이스 코드 흐름 및 XOAUTH2 지원 IMAP

사전 등록된 공개 클라이언트 nextxch-cli. 사용자가 표시된 주소를 열고 로그인하여 코드를 확인합니다.

참조 / 구성
# 1. Request a device code
curl -s https://mail.example.com/oauth/device_authorization \
  -d client_id=nextxch-cli -d "scope=mail offline_access"
# -> {"device_code":"...","user_code":"BCDF-GHJK","verification_uri":"https://mail.example.com/oauth/device",...}

# 2. Open https://mail.example.com/oauth/device in a browser, sign in, confirm code BCDF-GHJK

# 3. Poll every 5 seconds until the token arrives (authorization_pending / slow_down)
curl -s https://mail.example.com/oauth/token -d client_id=nextxch-cli \
  -d grant_type=urn:ietf:params:oauth:grant-type:device_code -d device_code=...

# 4. IMAP with the access token
curl -v --login-options AUTH=XOAUTH2 --oauth2-bearer "$ACCESS_TOKEN" \
  -u anna@example.com imaps://mail.example.com/INBOX

# 5. Refresh (the old refresh token becomes invalid) and revoke
curl -s https://mail.example.com/oauth/token -d client_id=nextxch-cli \
  -d grant_type=refresh_token -d refresh_token=nxrt_...
curl -s https://mail.example.com/oauth/revoke -d client_id=nextxch-cli -d token=nxrt_...

설정, 기본값 및 모범 사례

설정 / 위치 설명 기본값 프로덕션 모범 사례
Einschalten Admin > Identity sources > OAuth 2.1: "OAuth sign-in enabled". The issuer is the public address of the server. Discovery at /.well-known/oauth-authorization-server and /.well-known/openid-configuration, signing key (ES256) at /oauth/jwks. Aus 액세스 토큰 60분, 사용되지 않은 리프레시 토큰 90일, 최대 365일. 리프레시 토큰이 두 번 사용되면 전체 권한 부여가 취소됩니다(도용 방지).
Thunderbird PKCE 및 루프백 리디렉션이 포함된 사전 등록된 공개 클라이언트 "thunderbird". 자동 설정(/.well-known/autoconfig)은 비밀번호 다음의 두 번째 방법으로 OAuth2를 제공합니다. client_id thunderbird Thunderbird는 기본 제공 목록의 제공업체에 대해서만 OAuth2를 사용하며, 자체 서버의 경우 버전에 따라 다릅니다. 그때까지는 Kerberos/GSSAPI 또는 앱 비밀번호를 사용하십시오.
Outlook und Entra ID Entra 소스 및 "프로토콜에 대한 액세스 토큰 수락"이 설정된 경우 nextxch는 Entra 액세스 토큰(JWKS 서명, aud, v1 발급자 sts.windows.net 포함 iss, 만료 시간, 디렉터리)을 수락합니다. ActiveSync, EWS 및 MAPI는 "WWW-Authenticate: Bearer"를 알립니다. aud = api://mail.firma.de Entra: 애플리케이션 ID URI(api://mail.example.com) 및 범위(예: Mail.Access)가 포함된 자체 앱 등록 "nextxch Mail API". Windows용 Outlook이 자체 서버에 대해 최신 인증(Modern Auth)을 사용하는지 여부는 버전 및 Autodiscover에 따라 다르며, 회사 네트워크에서는 Kerberos가 가장 안정적인 방법입니다.
Eigene Anwendungen Admin-managed clients: public (PKCE) or confidential with a secret (shown once), redirect URIs exact or loopback with any port, flows code, refresh and device code, optionally without consent page. PKCE S256 Pflicht 범위: mail (모든 프로토콜), 단일 프로토콜 (imap, smtp, pop3, sieve, eas, ews, mapi, dav, jmap), offline_access, openid, email, profile.
Übersicht und Widerruf 사용자는 웹메일의 설정 > 보안에서 연결된 앱을 볼 수 있으며, 관리자는 관리자 > ID 소스 및 계정 대화 상자에서 모든 권한을 볼 수 있습니다. 권한 취소는 이미 발급된 액세스 토큰도 즉시 종료합니다. - 관리자가 AD 비밀번호를 재설정하면 해당 계정의 모든 OAuth 권한 부여가 자동으로 취소됩니다.