Elasticsearch 마스터 노트 시리즈 10편 (마지막). ES Security 무료 기능(8.x 기본 활성), TLS·HTTPS 설정, 사용자·Role 관리, API Key, Field·Document 레벨 보안, Audit Log, Spring Boot 통합 인증, 운영 보안 체크리스트, 시리즈 마무리.
이 글은 Elasticsearch 마스터 노트 시리즈의 마지막 열 번째 편입니다. 1~9편이 기능·운영이었다면, 이번엔 그것을 안전하게 — Security.
ES 8+ = 보안 기본 활성. TLS·인증 자동. Role 기반 권한. Field·Document 레벨 보안까지. 운영 환경 필수.
처음 ES Security가 어렵게 느껴지는 이유
처음 이 단원이 어렵게 느껴지는 이유는 두 가지예요. 첫째, 유료 vs 무료 기능이 헷갈립니다. 둘째, TLS 인증서 설정이 막연합니다.
해결법은 한 가지예요. "ES 8+ Security 기본 무료" 한 줄. 이전엔 X-Pack 유료, 8.0+ Basic 라이선스로 무료 활성. 운영 = 항상 켜기.
ES 8.x 기본 — Security 활성
# elasticsearch.yml (8.x 기본)
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl.enabled: true
xpack.security.transport.ssl.enabled: true
설치 시 자동:
- 자체 서명 인증서 생성
- elastic 사용자 비밀번호 설정
- HTTPS 활성
여기서 정말 중요한 시험 함정 — ES 8+ = 보안 기본 ON. 7.x = 기본 OFF·X-Pack 옵션. 운영 = 절대 OFF X.
첫 비밀번호 설정
# 자동 생성 비밀번호
bin/elasticsearch-reset-password -u elastic
# 또는 명시
bin/elasticsearch-reset-password -u elastic -i
elastic 사용자 = 슈퍼유저 (모든 권한).
TLS 설정
xpack.security.http.ssl:
enabled: true
keystore.path: certs/http.p12
truststore.path: certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
자체 서명 인증서 자동 생성. 운영 = CA 발급 인증서 권장.
여기서 정말 중요한 시험 함정 — HTTP TLS (클라이언트) + Transport TLS (노드 간) 둘 다. Transport 없으면 노드 간 평문 통신.
Spring Boot 클라이언트
spring:
elasticsearch:
uris: https://localhost:9200 # https
username: elastic
password: ${ES_PASSWORD}
# TLS 인증서 (자체 서명 시)
socket-timeout: 30s
ssl:
verify-hostname: false # 개발만
bundle: my-trust-bundle
spring:
ssl:
bundle:
pem:
my-trust-bundle:
truststore:
certificates: classpath:ca.crt
사용자 관리 — Native Realm
# 사용자 생성
POST /_security/user/alice
{
"password": "secure-pass",
"roles": ["read_only"],
"full_name": "Alice",
"email": "alice@example.com"
}
# 사용자 목록
GET /_security/user
# 비밀번호 변경
POST /_security/user/alice/_password
{
"password": "new-pass"
}
# 사용자 삭제
DELETE /_security/user/alice
또는 Kibana Stack Management UI.
Role — 권한 정의
POST /_security/role/products_writer
{
"cluster": ["monitor"],
"indices": [
{
"names": ["products", "products-*"],
"privileges": ["read", "write", "create_index"]
}
]
}
| 권한 그룹 | 권한 |
|---|---|
| Cluster | manage·monitor·all |
| Indices | read·write·create_index·delete_index·manage·all |
여기서 정말 중요한 시험 함정 — 권한은 명시적. 기본 = 거부. Role에 명시한 인덱스·동작만 허용.
빌트인 Role
superuser — 모든 권한 (elastic 사용자)
kibana_system — Kibana 전용
logstash_admin — Logstash
beats_admin — Beats
monitoring_user — 메트릭 조회
Role 매핑
POST /_security/role_mapping/admins
{
"roles": ["superuser"],
"enabled": true,
"rules": {
"any": [
{ "field": { "username": "alice" } },
{ "field": { "groups": "admins" } }
]
}
}
LDAP·SAML·OIDC 사용자 → Role 매핑.
Field-Level Security — 필드별 권한
POST /_security/role/products_public
{
"indices": [
{
"names": ["products"],
"privileges": ["read"],
"field_security": {
"grant": ["name", "price", "category"],
"except": ["internal_cost", "supplier_email"]
}
}
]
}
특정 필드 숨김. 민감 정보 보호.
Document-Level Security — 문서별 권한
POST /_security/role/region_us
{
"indices": [
{
"names": ["sales"],
"privileges": ["read"],
"query": {
"term": { "region": "US" }
}
}
]
}
조건 매칭 문서만 접근. 멀티 테넌트·지역별 권한.
여기서 정말 중요한 시험 함정 — Field·Document 보안 조합 = 강력한 멀티 테넌트. 같은 인덱스·다른 사용자가 다른 데이터.
API Key — 토큰 인증
POST /_security/api_key
{
"name": "my-app-key",
"role_descriptors": {
"products_role": {
"indices": [
{ "names": ["products"], "privileges": ["read"] }
]
}
},
"expiration": "30d"
}
# 응답
{
"id": "abc-123",
"name": "my-app-key",
"api_key": "very-secret-key",
"encoded": "YWJjLTEyMzp2ZXJ5LXNlY3JldC1rZXk=" # Base64
}
# 사용
curl -H "Authorization: ApiKey YWJjLTEyMzp2ZXJ5LXNlY3JldC1rZXk=" \
https://localhost:9200/products/_search
비밀번호 대신 API Key. 만료·세분화 권한.
여기서 시험 함정이 하나 있어요. API Key 운영 권장. 비밀번호보다 안전·만료·회전. 자동화·스크립트 권장.
OIDC·SAML — 외부 인증
xpack.security.authc.realms:
oidc:
oidc1:
order: 1
rp.client_id: "my-client"
rp.response_type: "code"
op.issuer: "https://auth.example.com"
op.authorization_endpoint: "..."
claims.principal: sub
외부 IdP (Keycloak·Okta·Auth0) 통합. SSO·MFA.
Audit Log
xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.include:
- access_granted
- access_denied
- authentication_failed
- connection_denied
모든 보안 이벤트 로그. 컴플라이언스·포렌식.
{
"@timestamp": "2024-01-15T10:30:00Z",
"event.action": "access_granted",
"user.name": "alice",
"indices": ["products"],
"request.method": "GET"
}
IP 필터링
xpack.security.transport.filter:
allow: "10.0.0.0/8"
deny: "0.0.0.0/0"
xpack.security.http.filter:
allow: ["10.0.0.0/8", "192.168.1.0/24"]
특정 IP만 접근.
운영 보안 체크리스트
✓ 보안 활성 (xpack.security.enabled: true)
✓ HTTP TLS + Transport TLS
✓ CA 발급 인증서 (운영)
✓ 강력한 elastic 비밀번호
✓ 일반 사용자 = 별도 (elastic 직접 사용 X)
✓ 최소 권한 Role (superuser 거의 X)
✓ Field/Document 보안 (민감 정보)
✓ API Key (자동화·만료·회전)
✓ Audit Log 활성
✓ IP 필터링 (가능 시)
✓ 외부 IdP 통합 (OIDC·SAML)
✓ 정기 비밀번호 회전
✓ 로그에 비밀번호 출력 X
✓ snapshot 암호화
CORS — Kibana·브라우저
http.cors.enabled: true
http.cors.allow-origin: "https://example.com"
http.cors.allow-methods: GET,POST,DELETE
http.cors.allow-credentials: true
브라우저 직접 접근 시 (보통 X·API Server 통해).
시리즈 마무리 — 10편 종합
1편부터 10편까지의 흐름:
| 편 | 주제 | 한 줄 |
|---|---|---|
| 1 | 기본 개념 | Lucene 위 분산 검색·역색인·5계층 |
| 2 | Mapping | text vs keyword, Dynamic 함정 |
| 3 | Analyzer | 토큰화 3 단계, Nori (한국어) |
| 4 | Query DSL | match·term·bool, Query vs Filter Context |
| 5 | Full-text Search | BM25, Highlighting, Suggester 3종 |
| 6 | Aggregations | Metrics·Bucket·Pipeline |
| 7 | Bulk API | NDJSON, Reindex, 성능 튜닝 |
| 8 | Spring 통합 | Repository·Operations·NativeQuery |
| 9 | 프로젝트 설계 | DB+ES 동기화·Alias·ILM |
| 10 | Security | TLS·Role·API Key·Audit |
ES의 거의 모든 운영 패턴을 한 번에 통찰할 토대.
시험 직전 한 번 더 — 자주 헷갈리는 함정 모음
여기까지가 10편의 핵심입니다. 시험 직전 또는 실무에서 헷갈릴 때 다시 펼쳐 볼 수 있게 압축 노트로 마무리할게요.
- ES 8+ Security 기본 ON (Basic 무료)
- 7.x는 기본 OFF·X-Pack 옵션
- HTTP TLS + Transport TLS 둘 다
- Transport 없으면 노드 간 평문
- 자체 서명 인증서 자동 / 운영 = CA 발급 권장
elastic= 슈퍼유저 (직접 사용 X)- 일반 사용자 = 별도·최소 권한
- Native Realm — 사용자·비밀번호·Role
- Role = Cluster 권한 + Indices 권한
- 빌트인 Role — superuser·kibana_system·monitoring_user 등
- Role Mapping = LDAP·SAML·OIDC 사용자 → Role
- Field-Level Security = 필드 숨김 (민감 정보)
- Document-Level Security = 문서 필터 (멀티 테넌트)
- 둘 조합 = 강력한 권한 분리
- API Key = 비밀번호 대안 (만료·회전·세분화)
- 자동화·스크립트 = API Key 권장
- OIDC·SAML = 외부 IdP (SSO·MFA)
- Audit Log = 보안 이벤트 (컴플라이언스)
- IP 필터링 =
transport.filter·http.filter - 운영 체크 — TLS·CA 인증서·강력 비밀번호·최소 권한·Field/Doc 보안·API Key·Audit·IP·외부 IdP
시리즈 다른 편 (시리즈 마지막)
- 1편 — 기본 개념·Cluster·Shard
- 2편 — Mapping·데이터 타입
- 3편 — Analyzer·Tokenizer·한국어
- 4편 — Query DSL
- 5편 — Full-text Search·Relevance
- 6편 — Aggregations
- 7편 — Bulk API·Reindex
- 8편 — Spring Data Elasticsearch
- 9편 — 검색 엔진 프로젝트 설계
- 10편 — Security·인증·인가·TLS (현재 글, 시리즈 마지막)
공식 문서: Elasticsearch Security 에서 더 깊이.
Elasticsearch 마스터 시리즈는 여기서 마무리. 1편부터 10편까지의 흐름이 머리에 남으면 검색 엔진의 거의 모든 운영 패턴을 손에 잡고 시작할 토대가 됩니다.