Post

SAML

SAML

What is SAML (Security Assertion Markup Language)?

SAML is an open-standard protocol for web-based authentication and authorization. It is widely used to implement Single Sign-On (SSO), allowing users to access multiple services with a single login.

Basic Components of SAML

SAML consists of three main components:

1. Principal (User)

The individual who attempts to access a service.

2. Service Provider (SP)

The web service or application the user wants to access.

3. Identity Provider (IdP)

The entity that verifies the user’s identity and performs authentication.

Example of SAML Authentication Flow

When a user attempts to access a service, authentication occurs through the following steps:

  1. The user accesses the Service Provider (SP) via a web browser.
  2. The SP detects the user is not authenticated and sends an authentication request to the Identity Provider (IdP).
  3. The user is redirected to the IdP, where they authenticate using credentials (e.g., username and password).
  4. Upon successful authentication, the IdP generates a SAML assertion (an XML token containing authentication information) and redirects the user back to the SP.
  5. The SP validates the received assertion from the IdP and grants access to the user.

Structure of a SAML Assertion

A SAML Assertion contains three primary types of information:

  • Authentication Statement: Information about when and how the user was authenticated.
  • Attribute Statement: Additional attributes about the user (e.g., email, name).
  • Authorization Decision Statement: Information about whether the user has permission to access a specific resource.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<saml:Assertion>
    <saml:AuthenticationStatement AuthenticationInstant="2025-05-01T10:30:00Z">
        <saml:AuthnContext>
            <saml:AuthnContextClassRef>PasswordProtectedTransport</saml:AuthnContextClassRef>
        </saml:AuthnContext>
    </saml:AuthenticationStatement>
    <saml:AttributeStatement>
        <saml:Attribute Name="email">
            <saml:AttributeValue>user@example.com</saml:AttributeValue>
        </saml:Attribute>
    </saml:AttributeStatement>
    <saml:AuthorizationDecisionStatement Resource="https://example.com/app">
        <saml:Decision>Permit</saml:Decision>
    </saml:AuthorizationDecisionStatement>
</saml:Assertion>

SAML Bindings

The primary binding methods used in SAML are:

  • HTTP-Redirect Binding: Transfers SAML messages via URL parameters.
  • HTTP-POST Binding: Transfers SAML messages within the HTTP POST request body, enhancing security.

Security Mechanisms in SAML Assertions

SAML assertions use the following methods to ensure security:

  • Digital Signature: Ensures the integrity and authenticity of the assertion.
  • Encryption: Protects assertions containing sensitive information through encryption.

Examples of SAML Request and Response

A SAML Request represents an authentication request and has the following form:

1
2
3
<samlp:AuthnRequest>
    <saml:Issuer>https://sp.example.com</saml:Issuer>
</samlp:AuthnRequest>

A SAML Response includes the assertion and has the following structure:

1
2
3
4
5
<samlp:Response>
    <saml:Assertion>
        <!-- Authentication, attribute, and authorization information included here -->
    </saml:Assertion>
</samlp:Response>

Comparison of SAML with Other Protocols (OAuth, OpenID Connect)

  • OAuth: Focuses primarily on authorization, suitable for granting API access.
  • OpenID Connect: An authentication layer built on OAuth, suitable for authentication and identity management, uses JSON format.
  • SAML: XML-based authentication protocol commonly used in enterprise SSO implementations.

Key Security Considerations for SAML

  • Replay Attack Prevention: Uses timestamps and unique identifiers (IDs) to prevent replay attacks.
  • XML Signature Wrapping Attack Mitigation: Ensures proper XML signature validation to prevent man-in-the-middle attacks.
  • Assertion Validity Period Management: Sets short validity periods to minimize exposure risk.

Benefits of Using SAML

  • Enhanced Security: User passwords are managed only by the IdP, reducing exposure across multiple services.
  • Improved Convenience: Users can access multiple services with a single authentication.
  • Centralized Management: Organizations can centrally manage user permissions and authentication, simplifying maintenance.

Real-world Use Cases of SAML

Typical use cases in enterprise environments include:

  • Allowing employees to access internal business systems (email, HR systems, CRM, etc.) with a single account.
  • Managing access permissions to external cloud services (e.g., Salesforce, Office 365) through integration with enterprise authentication systems.

For example, when a user logs into Google Workspace, they can seamlessly access cloud services such as Salesforce or Dropbox without additional login processes.


SAML (Security Assertion Markup Language)이란?

SAML은 웹 기반 인증과 권한 부여를 위한 개방형 표준 프로토콜입니다. 사용자가 한 번의 로그인으로 여러 서비스에 접근할 수 있도록 해주는 Single Sign-On(SSO)을 구현할 때 널리 사용됩니다.

SAML의 기본 구성요소

SAML은 세 가지 주요 구성요소로 이루어져 있습니다.

1. Principal (사용자)

서비스에 접근하려는 사용자를 의미합니다.

2. Service Provider (SP)

사용자가 접근하고자 하는 웹 서비스나 애플리케이션입니다.

3. Identity Provider (IdP)

사용자의 신원을 확인하고 인증을 수행하는 주체입니다.

SAML 인증 흐름 예시

사용자가 특정 서비스에 접근하려 할 때, 다음과 같은 흐름을 통해 인증이 이루어집니다.

  1. 사용자가 웹 브라우저를 통해 서비스 제공자(SP)에 접근합니다.
  2. 서비스 제공자는 사용자가 인증되지 않은 상태라는 것을 확인하고, 인증 요청을 Identity Provider(IdP)에 전송합니다.
  3. 사용자는 IdP로 리다이렉트되어 IdP에서 사용자 인증(아이디, 비밀번호 등)을 수행합니다.
  4. IdP는 사용자 인증이 성공하면 SAML assertion(인증 정보가 담긴 XML 형식의 토큰)을 생성하여 사용자를 다시 SP로 리다이렉트합니다.
  5. SP는 IdP로부터 받은 assertion의 유효성을 검증한 후, 사용자의 접근을 허용합니다.

SAML Assertion의 구조

SAML Assertion은 다음의 세 가지 주요 정보를 포함합니다.

  • Authentication Statement: 사용자가 언제 어떤 방법으로 인증되었는지에 대한 정보
  • Attribute Statement: 사용자와 관련된 추가적인 속성 정보(예: 이메일, 이름 등)
  • Authorization Decision Statement: 사용자가 특정 리소스에 접근할 권한이 있는지에 대한 정보
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<saml:Assertion>
    <saml:AuthenticationStatement AuthenticationInstant="2025-05-01T10:30:00Z">
        <saml:AuthnContext>
            <saml:AuthnContextClassRef>PasswordProtectedTransport</saml:AuthnContextClassRef>
        </saml:AuthnContext>
    </saml:AuthenticationStatement>
    <saml:AttributeStatement>
        <saml:Attribute Name="email">
            <saml:AttributeValue>user@example.com</saml:AttributeValue>
        </saml:Attribute>
    </saml:AttributeStatement>
    <saml:AuthorizationDecisionStatement Resource="https://example.com/app">
        <saml:Decision>Permit</saml:Decision>
    </saml:AuthorizationDecisionStatement>
</saml:Assertion>

SAML 바인딩(Binding)

SAML에서 사용되는 주요 바인딩 방식은 다음과 같습니다.

  • HTTP-Redirect Binding: SAML 메시지를 URL 파라미터로 전달하는 방식입니다.
  • HTTP-POST Binding: SAML 메시지를 HTTP POST 요청의 본문으로 전달하는 방식으로 보안이 상대적으로 강화됩니다.

SAML Assertion의 보안 메커니즘

SAML Assertion은 보안을 위해 다음의 방법들을 사용합니다.

  • 디지털 서명: Assertion의 무결성과 신뢰성을 보장하기 위해 디지털 서명이 적용됩니다.
  • 암호화: 민감한 정보가 담긴 Assertion은 암호화하여 보호합니다.

SAML 요청(Request) 및 응답(Response) 예시

SAML 요청은 인증 요청을 나타내며, 다음과 같은 형태를 가집니다.

1
2
3
<samlp:AuthnRequest>
    <saml:Issuer>https://sp.example.com</saml:Issuer>
</samlp:AuthnRequest>

SAML 응답은 Assertion을 포함하며, 아래와 같이 구성됩니다.

1
2
3
4
5
<samlp:Response>
    <saml:Assertion>
        <!-- 인증, 속성, 권한 정보 포함 -->
    </saml:Assertion>
</samlp:Response>

SAML과 다른 프로토콜 비교 (OAuth, OpenID Connect)

  • OAuth: 권한 부여에 초점이 있으며, API 접근 권한 부여에 적합합니다.
  • OpenID Connect: OAuth의 인증 레이어로, 인증과 ID 관리에 적합하며 JSON 포맷을 사용합니다.
  • SAML: XML 기반의 인증 프로토콜로 기업 환경의 SSO 구현에 주로 사용됩니다.

SAML 주요 보안 고려사항

  • Replay 공격 방지: Timestamp와 고유한 식별자(ID)를 통해 중복 사용을 방지합니다.
  • XML Signature Wrapping 공격 대응: XML 서명을 정확히 검증하여 중간자 공격을 방지합니다.
  • Assertion 유효 기간 관리: 짧은 유효 기간을 설정하여 노출 위험을 최소화합니다.

SAML 사용 시의 장점

  • 보안 강화: 사용자의 비밀번호가 여러 서비스에 분산되지 않고 IdP에서만 관리되어 보안이 향상됩니다.
  • 편의성 향상: 사용자는 단 한 번의 인증으로 여러 서비스에 접근할 수 있어 편의성이 높습니다.
  • 중앙화된 관리: 기업이나 기관 입장에서 사용자의 권한과 인증을 중앙 집중적으로 관리할 수 있어 유지보수가 용이합니다.

SAML의 실제 활용 사례

기업 환경에서 사용되는 대표적인 예로는:

  • 직원들이 내부 업무 시스템(이메일, 인사 시스템, CRM 등)에 하나의 계정으로 접근하도록 구성
  • 외부 클라우드 서비스(SaaS)에 대한 접근 권한을 기업 내 인증 시스템과 통합하여 관리 (예: Salesforce, Office 365)

예를 들어, 사용자가 구글 워크스페이스(Google Workspace)에 로그인하면, 같은 세션에서 Salesforce나 Dropbox와 같은 클라우드 서비스에 별도의 로그인 과정 없이 접근할 수 있습니다.

This post is licensed under CC BY 4.0 by the author.