SAML 메타데이터

SAML 메타데이터 (Metadata)

SP와 IdP가 서로를 처음 알 때, "내 끝점은 어디고, 어떤 바인딩을 지원하고, 어떤 인증서를 써요"라는 정보를 일일이 수작업으로 정하지 않아도 되게 해주는 게 SAML 메타데이터예요. 엔티티(IdP, SP 등)의 식별자, 바인딩 지원, 끝점, 인증서와 키에 대한 합의를 표준화된 XML로 기술하고, 이를 서로 교환해서 통합을 자동화할 수 있게 하지요. 시스템 엔티티들의 이 정보가 이 문서에 담긴다고 이해하면 돼요.

출처: Metadata for the OASIS Security Assertion Markup Language (SAML) V2.0

본문

SAML 메타데이터는 XML로 작성되고, 메타데이터 전용 네임스페이스인 urn:oasis:names:tc:SAML:2.0:metadata(관례상 md:)를 사용해요. 한 문서의 최상위 요소는 **<EntityDescriptor>**로, 하나의 엔티티(SAML 시스템 엔티티)를 나타내요.

<EntityDescriptor> — 엔티티 문서의 뼈대

엔티티 하나는 고유한 entityID를 갖고, 그 아래에 역할(role)별 기술자를 둬요.

<element name="EntityDescriptor" type="md:EntityDescriptorType"/>
<complexType name="EntityDescriptorType">
    <sequence>
        <element ref="ds:Signature" minOccurs="0"/>
        <element ref="md:Extensions" minOccurs="0"/>
        <choice>
            <choice maxOccurs="unbounded">
                <element ref="md:RoleDescriptor"/>
                <element ref="md:IDPSSODescriptor"/>
                <element ref="md:SPSSODescriptor"/>
                <element ref="md:AuthnAuthorityDescriptor"/>
                <element ref="md:AttributeAuthorityDescriptor"/>
                <element ref="md:PDPDescriptor"/>
            </choice>
            <element ref="md:AffiliationDescriptor"/>
        </choice>
        <element ref="md:Organization" minOccurs="0"/>
        <element ref="md:ContactPerson" minOccurs="0" maxOccurs="unbounded"/>
        <element ref="md:AdditionalMetadataLocation" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    <attribute name="entityID" type="md:entityIDType" use="required"/>
    <attribute name="validUntil" type="dateTime" use="optional"/>
    <attribute name="cacheDuration" type="duration" use="optional"/>
    <attribute name="ID" type="ID" use="optional"/>
    <anyAttribute namespace="##other" processContents="lax"/>
</complexType>

entityID는 필수 속성이고, validUntilcacheDuration은 메타데이터의 유효기간을 정해요.

역할 기술자 — IdP와 SP

역할은 **<RoleDescriptor>**에서 파생되는 기술자로 표현돼요. protocolSupportEnumeration은 그 기술자가 지원하는 프로토콜 URI 목록을 나타내는데, SAML 2.0 엔티티라면 urn:oasis:names:tc:SAML:2.0:protocol을 반드시 포함해야 해요.

**IdP는 <IDPSSODescriptor>**로 기술하고, SSO 관련 끝점과 키를 가져요.

<element name="IDPSSODescriptor" type="md:IDPSSODescriptorType"/>
<complexType name="IDPSSODescriptorType">
    <complexContent>
        <extension base="md:SSODescriptorType">
            <sequence>
                <element ref="md:SingleSignOnService" maxOccurs="unbounded"/>
                <element ref="md:NameIDMappingService" minOccurs="0" maxOccurs="unbounded"/>
                <element ref="md:AssertionIDRequestService" minOccurs="0" maxOccurs="unbounded"/>
                <element ref="md:AttributeProfile" minOccurs="0" maxOccurs="unbounded"/>
                <element ref="saml:Attribute" minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
            <attribute name="WantAuthnRequestsSigned" type="boolean" use="optional"/>
        </extension>
    </complexContent>
</complexType>

**SP는 <SPSSODescriptor>**로 기술하고, 어써션을 받는 끝점(AssertionConsumerService)과 원하는 속성(AttributeConsumingService)을 선언해요.

<element name="SPSSODescriptor" type="md:SPSSODescriptorType"/>
<complexType name="SPSSODescriptorType">
    <complexContent>
        <extension base="md:SSODescriptorType">
            <sequence>
                <element ref="md:AssertionConsumerService" maxOccurs="unbounded"/>
                <element ref="md:AttributeConsumingService" minOccurs="0" maxOccurs="unbounded"/>
            </sequence>
            <attribute name="AuthnRequestsSigned" type="boolean" use="optional"/>
            <attribute name="WantAssertionsSigned" type="boolean" use="optional"/>
        </extension>
    </complexContent>
</complexType>

SSO 관련 공통 요소는 추상 타입 SSODescriptorType에 모여 있어요. 싱글 로그아웃 끝점 SingleLogoutService와 지원하는 NameIDFormat이 여기 포함되지요.

키와 끝점

서명·암호화에 쓰는 공개키는 **<KeyDescriptor>**에 담겨요. use 속성에 따라 signing(서명)인지 encryption(암호화)인지 구분하고, 실제 키는 XML 서명의 ds:KeyInfo 안에 실어요.

<element name="KeyDescriptor" type="md:KeyDescriptorType"/>
<complexType name="KeyDescriptorType">
    <sequence>
        <element ref="ds:KeyInfo"/>
        <element ref="md:EncryptionMethod" minOccurs="0" maxOccurs="unbounded"/>
    </sequence>
    <attribute name="use" type="md:KeyTypes" use="optional"/>
</complexType>

끝점은 EndpointType 기반의 요소들(SingleSignOnService, SingleLogoutService, AssertionConsumerService 등)로 선언하고, 각각 Binding(바인딩 URI)과 Location(URL)을 가져요. 이렇게 해서 "이 IdP의 SSO 끝점은 이 URL이고 Redirect/POST를 지원한다" 같은 합의가 한 문서에 담기는 거예요.

메타데이터 신뢰

메타데이터 위에 정의된 요소 대부분은 개별적으로 서명할 수 있어서, 신뢰성을 확보하는 다양한 보안 메커니즘을 지원해요. 실제 운영에서는 엔티티 문서를 서명해 배포하거나, 신뢰할 수 있는 출처에서 받아 쓰는 방식을 권장해요.

더 알아보기

  • SAML 브라우저 SSO 플로 — 메타데이터로 끝점을 알아내는 인증 흐름.
  • SAML 바인딩 — 끝점의 Binding 속성이 가리키는 전송 방식.
  • SAML 어써션 — 메타데이터에 선언된 키로 검증하는 어써션.