스마트 카드 인증
Offering: GitLab Self-Managed
GitLab은 스마트 카드를 사용한 인증을 지원합니다. 기본적으로 스마트 카드 인증이 활성화된 경우 기존 사용자는 사용자 이름과 비밀번호로 계속 로그인할 수 있습니다. 기존 사용자가 스마트 카드 인증만 사용하도록 강제하려면 사용자 이름 및 비밀번호 인증을 비활성화합니다.
GitLab은 스마트 카드를 사용한 인증을 지원합니다.
기존 비밀번호 인증#
기본적으로 스마트 카드 인증이 활성화된 경우 기존 사용자는 사용자 이름과 비밀번호로 계속 로그인할 수 있습니다.
기존 사용자가 스마트 카드 인증만 사용하도록 강제하려면 사용자 이름 및 비밀번호 인증을 비활성화합니다.
인증 방법#
GitLab은 두 가지 인증 방법을 지원합니다:
- 로컬 데이터베이스를 사용하는 X.509 인증서.
- LDAP 서버.
로컬 데이터베이스와 X.509 인증서를 사용한 인증#
X.509 인증서가 있는 스마트 카드를 GitLab에서 인증하는 데 사용할 수 있습니다.
GitLab과 함께 로컬 데이터베이스에 대해 인증하는 데 X.509 인증서가 있는 스마트 카드를 사용하려면 인증서에 CN 및 emailAddress가 정의되어 있어야 합니다. 예를 들면:
Certificate:
Data:
Version: 1 (0x0)
Serial Number: 12856475246677808609 (0xb26b601ecdd555e1)
Signature Algorithm: sha256WithRSAEncryption
Issuer: O=Random Corp Ltd, CN=Random Corp
Validity
Not Before: Oct 30 12:00:00 2018 GMT
Not After : Oct 30 12:00:00 2019 GMT
Subject: CN=Gitlab User, emailAddress=gitlab-user@example.com
로컬 데이터베이스와 SAN 확장을 사용하는 X.509 인증서를 통한 인증#
SAN 확장을 사용하는 X.509 인증서가 있는 스마트 카드를 GitLab에서 인증하는 데 사용할 수 있습니다.
GitLab과 함께 로컬 데이터베이스에 대해 인증하는 데 X.509 인증서가 있는 스마트 카드를 사용하려면:
subjectAltName(SAN) 확장 중 하나 이상이 GitLab 인스턴스(URI) 내의 사용자 ID(email)를 정의해야 합니다.URI는Gitlab.config.host.gitlab과 일치해야 합니다.- 인증서에 하나의 SAN 이메일 항목만 포함된 경우
email을URI와 일치시키기 위해 추가하거나 수정할 필요가 없습니다.
예를 들면:
Certificate:
Data:
Version: 1 (0x0)
Serial Number: 12856475246677808609 (0xb26b601ecdd555e1)
Signature Algorithm: sha256WithRSAEncryption
Issuer: O=Random Corp Ltd, CN=Random Corp
Validity
Not Before: Oct 30 12:00:00 2018 GMT
Not After : Oct 30 12:00:00 2019 GMT
...
X509v3 extensions:
X509v3 Key Usage:
Key Encipherment, Data Encipherment
X509v3 Extended Key Usage:
TLS Web Server Authentication
X509v3 Subject Alternative Name:
email:gitlab-user@example.com, URI:http://gitlab.example.com/
LDAP 서버에 대한 인증#
GitLab은 RFC4523을 따라 표준 인증서 매칭 방법을 구현합니다. userCertificate 속성에 대해 certificateExactMatch 인증서 매칭 규칙을 사용합니다. 전제 조건으로 다음을 갖춘 LDAP 서버를 사용해야 합니다:
certificateExactMatch매칭 규칙을 지원합니다.userCertificate속성에 인증서가 저장되어 있습니다.
Active Directory LDAP 서버에 대한 인증#
히스토리
- GitLab 16.9에서 도입되었습니다.
- GitLab 17.11에서
reverse_issuer_and_subject및reverse_issuer_and_serial_number형식이 추가되었습니다. issuer_and_subject,reverse_issuer_and_subject및subject형식이 GitLab 18.6에서smartcard_ad_formats_v2라는 플래그와 함께 업데이트되었습니다. 기본적으로 활성화됩니다. 이 플래그를 비활성화하면 이러한 형식이 이전 버전으로 되돌아갑니다.- GitLab 18.9에서 일반적으로 사용 가능합니다. 기능 플래그
smartcard_ad_formats_v2가 제거되었습니다.
이 기능의 기능은 기능 플래그에 의해 제어됩니다. 자세한 내용은 기록을 참조하세요.
Active Directory는 certificateExactMatch 규칙 또는 userCertificate 속성을 지원하지 않습니다. 스마트 카드 등 인증서 기반 인증을 위한 대부분의 도구는 각 사용자에 대해 여러 인증서를 포함할 수 있는 altSecurityIdentities 속성을 사용합니다. 필드의 데이터는 Microsoft에서 권장하는 형식 중 하나와 일치해야 합니다.
다음 속성을 사용하여 GitLab이 확인하는 필드와 인증서 데이터 형식을 사용자 지정합니다:
smartcard_ad_cert_field- 검색할 필드 이름을 지정합니다. 사용자 개체의 모든 속성일 수 있습니다.smartcard_ad_cert_format- 인증서에서 수집한 정보의 형식을 지정합니다. 이 형식은 다음 값 중 하나여야 합니다. 비-Active Directory LDAP 서버의 동작과 일치하는 가장 일반적인 것은issuer_and_serial_number입니다.
smartcard_ad_cert_format |
예시 데이터 |
|---|---|
principal_name |
X509:alice@example.com |
rfc822_name |
X509:bob@example.com |
subject |
X509:<S>CN=dennis,OU=UserAccounts,DC=example,DC=com |
issuer_and_serial_number |
X509:<I>CN=CONTOSO-DC-CA,DC=example,DC=com1181914561 |
issuer_and_subject |
X509:<I>CN=EXAMPLE-DC-CA,DC=example,DC=com<S>CN=cynthia,OU=UserAccounts,DC=example,DC=com |
reverse_issuer_and_serial_number |
X509:<I>DC=com,DC=example,CN=CONTOSO-DC-CA1181914561 |
reverse_issuer_and_subject |
X509:<I>DC=com,DC=example,CN=CONTOSO-DC-CA<S>CN=cynthia,OU=UserAccounts,DC=example,DC=com |
reverse_issuer_and_reverse_subject |
X509:<I>DC=com,DC=example,CN=CONTOSO-DC-CA<S>DC=com,DC=example,OU=UserAccounts,CN=cynthia |
issuer_and_serial_number의 경우 부분은 가장 유효하지 않은 바이트가 먼저 오는 역바이트 순서입니다. 자세한 내용은 altSecurityIdentities 속성에서 사용 가능한 모든 방법을 통해 인증서에 사용자를 매핑하는 방법을 참조하세요.
역 발급자 형식은 가장 작은 단위에서 가장 큰 단위로 발급자 문자열을 정렬합니다. 일부 Active Directory 서버는 이 형식으로 인증서를 저장합니다.
smartcard_ad_cert_format이 지정되지 않았지만 LDAP 서버가 active_directory: true로 구성되고 스마트 카드가 활성화된 경우 GitLab은 16.8 이전 버전의 동작으로 기본값을 설정하고 userCertificate 속성에서 certificateExactMatch를 사용합니다.
Entra ID 도메인 서비스에 대한 인증#
히스토리
- GitLab 16.9에서 도입되었습니다.
이전에 Azure Active Directory로 알려진 Microsoft Entra ID는 회사와 조직을 위한 클라우드 기반 디렉토리를 제공합니다. Entra 도메인 서비스는 디렉토리에 대한 보안 읽기 전용 LDAP 인터페이스를 제공하지만 Entra ID가 가진 필드의 제한된 하위 집합만 노출합니다.
Entra ID는 CertificateUserIds 필드를 사용하여 사용자의 클라이언트 인증서를 관리하지만 이 필드는 LDAP / Entra ID 도메인 서비스에 노출되지 않습니다. 클라우드 전용 설정에서는 GitLab이 LDAP를 사용하여 사용자의 스마트 카드를 인증하는 것이 불가능합니다.
하이브리드 온-프레미스 및 클라우드 환경에서 엔터티는 Entra Connect를 사용하여 온-프레미스 Active Directory 컨트롤러와 클라우드 Entra ID 간에 동기화됩니다. Entra ID Connect를 사용하여 altSecurityIdentities 속성을 Entra ID의 certificateUserIds에 동기화하는 경우 GitLab에서 인증할 수 있도록 이 데이터를 LDAP / Entra ID 도메인 서비스에 노출할 수 있습니다:
- Entra ID Connect에 규칙을 추가하여
altSecurityIdentities를 Entra ID의 추가 속성에 동기화합니다. - Entra ID 도메인 서비스에서 확장 속성으로 해당 추가 속성을 활성화합니다.
- GitLab의
smartcard_ad_cert_field필드를 이 확장 속성을 사용하도록 구성합니다.
스마트 카드 인증을 위한 GitLab 구성#
Linux 패키지 설치의 경우:
-
/etc/gitlab/gitlab.rb를 편집합니다:# Allow smart card authentication gitlab_rails['smartcard_enabled'] = true # Path to a file containing a CA certificate gitlab_rails['smartcard_ca_file'] = "/etc/ssl/certs/CA.pem" # Host and port where the client side certificate is requested by the # webserver (NGINX/Apache) gitlab_rails['smartcard_client_certificate_required_host'] = "smartcard.example.com" gitlab_rails['smartcard_client_certificate_required_port'] = 3444[!note] 다음 변수 중 하나 이상에 값을 할당합니다:
gitlab_rails['smartcard_client_certificate_required_host']또는gitlab_rails['smartcard_client_certificate_required_port']. -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재구성합니다.
소스 설치의 경우:
-
클라이언트 측 인증서를 요청하도록 NGINX를 구성합니다
NGINX 구성에서 다음을 제외하고 동일한 구성으로 추가 서버 컨텍스트를 정의해야 합니다:
-
추가 NGINX 서버 컨텍스트는 다른 포트에서 실행되도록 구성해야 합니다:
listen *:3444 ssl; -
다른 호스트명에서 실행되도록 구성할 수도 있습니다:
listen smartcard.example.com:443 ssl; -
추가 NGINX 서버 컨텍스트는 클라이언트 측 인증서를 요청하도록 구성해야 합니다:
ssl_verify_depth 2; ssl_client_certificate /etc/ssl/certs/CA.pem; ssl_verify_client on; -
추가 NGINX 서버 컨텍스트는 클라이언트 측 인증서를 전달하도록 구성해야 합니다:
proxy_set_header X-SSL-Client-Certificate $ssl_client_escaped_cert;
예를 들어 다음은 NGINX 구성 파일(예:
/etc/nginx/sites-available/gitlab-ssl)의 예시 서버 컨텍스트입니다:server { listen smartcard.example.com:3443 ssl; # certificate for configuring SSL ssl_certificate /path/to/example.com.crt; ssl_certificate_key /path/to/example.com.key; ssl_verify_depth 2; # CA certificate for client side certificate verification ssl_client_certificate /etc/ssl/certs/CA.pem; ssl_verify_client on; location / { proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; proxy_set_header X-SSL-Client-Certificate $ssl_client_escaped_cert; proxy_read_timeout 300; proxy_pass http://gitlab-workhorse; } } -
-
config/gitlab.yml을 편집합니다:## Smart card authentication settings smartcard: # Allow smart card authentication enabled: true # Path to a file containing a CA certificate ca_file: '/etc/ssl/certs/CA.pem' # Host and port where the client side certificate is requested by the # webserver (NGINX/Apache) client_certificate_required_host: smartcard.example.com client_certificate_required_port: 3443[!note] 다음 변수 중 하나 이상에 값을 할당합니다:
client_certificate_required_host또는client_certificate_required_port. -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재시작합니다.
추가 보안 권장 사항#
추가 보안을 위해 CloudFlare WAF나 ModSecurity를 실행하는 서버와 같은 방화벽 뒤에 GitLab을 배포하세요. 다음 패턴과 일치하는 URL은 GitLab의 일부로 배포된 NGINX에서 액세스할 수 있어야 하지만 외부 클라이언트에서는 액세스할 수 없어야 합니다:
/-/smartcard/extract_certificate
/-/smartcard/verify_certificate
이 경로는 NGINX에 할당된 스마트 카드 호스트명과 포트를 사용하여 외부에서만 액세스할 수 있어야 하며 기본 GitLab 호스트명과 포트를 사용하여 외부에서 액세스할 수 없어야 합니다. 이것은 사용자가 NGINX를 통하지 않고 자체 인증서 매개변수를 제출할 수 없도록 HTTP Host Header 공격에 대한 강력한 보호를 제공해야 합니다.
SAN 확장을 사용할 때 추가 단계#
Linux 패키지 설치의 경우:
-
/etc/gitlab/gitlab.rb에 추가합니다:gitlab_rails['smartcard_san_extensions'] = true -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재구성합니다.
소스 설치의 경우:
-
스마트 카드 섹션 내
config/gitlab.yml에san_extensions행을 추가합니다:smartcard: enabled: true ca_file: '/etc/ssl/certs/CA.pem' client_certificate_required_port: 3444 # Enable the use of SAN extensions to match users with certificates san_extensions: true -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재시작합니다.
LDAP 서버에 대해 인증할 때 추가 단계#
Linux 패키지 설치의 경우:
-
/etc/gitlab/gitlab.rb를 편집합니다:gitlab_rails['ldap_servers'] = YAML.load <<-EOS main: # snip... # Enable smart card authentication against the LDAP server. Valid values # are "false", "optional", and "required". smartcard_auth: optional # If your LDAP server is Active Directory, you can configure these two fields. # Specify which field contains certificate information, 'altSecurityIdentities' by default smartcard_ad_cert_field: altSecurityIdentities # Specify format of certificate information. Valid values are: # principal_name, rfc822_name, issuer_and_subject, subject, issuer_and_serial_number smartcard_ad_cert_format: issuer_and_serial_number EOS -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재구성합니다.
소스 설치의 경우:
-
config/gitlab.yml을 편집합니다:production: ldap: servers: main: # snip... # Enable smart card authentication against the LDAP server. Valid values # are "false", "optional", and "required". smartcard_auth: optional # If your LDAP server is Active Directory, you can configure these two fields. # Specify which field contains certificate information, 'altSecurityIdentities' by default smartcard_ad_cert_field: altSecurityIdentities # Specify format of certificate information. Valid values are: # principal_name, rfc822_name, issuer_and_subject, subject, issuer_and_serial_number smartcard_ad_cert_format: issuer_and_serial_number -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재시작합니다.
Git 액세스를 위한 스마트 카드 로그인으로 브라우저 세션 요구#
Linux 패키지 설치의 경우:
-
/etc/gitlab/gitlab.rb를 편집합니다:gitlab_rails['smartcard_required_for_git_access'] = true -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재구성합니다.
소스 설치의 경우:
-
config/gitlab.yml을 편집합니다:## Smart card authentication settings smartcard: # snip... # Browser session with smart card sign-in is required for Git access required_for_git_access: true -
파일을 저장하고 변경 사항이 적용되도록 GitLab을 재시작합니다.
스마트 카드 인증을 통해 생성된 사용자의 비밀번호#
통합 인증을 통해 생성된 사용자의 생성 비밀번호 가이드는 GitLab이 스마트 카드 인증을 통해 생성된 사용자의 비밀번호를 생성하고 설정하는 방법에 대한 개요를 제공합니다.
