# Mattermost Community Enterprise - 확장 기능 문서 이 문서는 Team Edition에서 Enterprise 기능을 활성화하기 위해 생성/수정된 파일과 버전 업그레이드 시 이식해야 할 내용을 정리합니다. --- ## 프로젝트 구조 ``` mattermost-community-enterprise/ ├── enterprise/ # Enterprise 브릿지 (기존) │ └── community_imports.go # enterprise-community 임포트 ├── enterprise-impl/ # [신규] Enterprise 구현체 │ ├── enterprise.go # 메인 등록 파일 │ ├── go.mod # 별도 모듈 정의 │ ├── go.sum │ ├── ldap/ # LDAP 구현 │ ├── saml/ # SAML 구현 │ ├── cluster/ # 클러스터링 구현 │ ├── metrics/ # Prometheus 메트릭 구현 │ ├── compliance/ # 컴플라이언스 구현 │ ├── data_retention/ # 데이터 보존 구현 │ ├── message_export/ # 메시지 내보내기 구현 │ ├── account_migration/ # 계정 마이그레이션 구현 │ ├── access_control/ # 접근 제어 구현 │ ├── ip_filtering/ # IP 필터링 구현 │ ├── notification/ # 알림 구현 │ ├── oauthproviders/ # OAuth 프로바이더 구현 │ ├── outgoing_oauth_connection/ # 외부 OAuth 연결 구현 │ ├── push_proxy/ # 푸시 프록시 구현 │ └── searchengine/ # 검색 엔진 구현 ├── enterprise-community/ # [신규] Enterprise 등록 파일 │ ├── imports.go # 모든 구현체 임포트 │ ├── ldap/init.go │ ├── saml/init.go │ ├── cluster/init.go │ ├── metrics/init.go │ ├── compliance/init.go │ ├── data_retention/init.go │ ├── message_export/init.go │ ├── account_migration/init.go │ ├── access_control/init.go │ ├── ip_filtering/init.go │ ├── notification/init.go │ ├── outgoing_oauth_connection/init.go │ ├── push_proxy/init.go │ └── searchengine/init.go ├── channels/api4/ # [수정됨] API 라이선스 체크 제거 │ ├── ldap.go │ ├── saml.go │ ├── user.go │ ├── group.go │ └── scheme.go ├── channels/app/platform/ # [수정됨] 메트릭 핸들러 │ └── metrics.go ├── Dockerfile.local # [신규] 로컬 빌드용 Dockerfile ├── Dockerfile.mattermost # [신규] Git 빌드용 Dockerfile ├── README.md # [신규] 빌드 가이드 ├── Extend-Function.md # [신규] 이 문서 └── Unlock-License.md # [신규] 라이선스 해제 문서 ``` --- ## 생성된 파일 상세 ### 1. enterprise-impl/ (Enterprise 구현체) #### enterprise-impl/enterprise.go Enterprise 기능 등록을 위한 메인 파일입니다. ```go package enterprise import ( "github.com/mattermost/mattermost/server/v8/channels/app" "github.com/mattermost/mattermost/server/v8/enterprise-impl/ldap" "github.com/mattermost/mattermost/server/v8/enterprise-impl/cluster" "github.com/mattermost/mattermost/server/v8/enterprise-impl/metrics" // ... 기타 imports ) func init() { app.RegisterLdapInterface(ldap.New) app.RegisterClusterInterface(cluster.New) app.RegisterMetricsInterface(metrics.New) // ... 기타 등록 } ``` #### enterprise-impl/ldap/ldap.go LDAP 인증 및 동기화 구현체입니다. 주요 메서드: - `DoLogin()` - LDAP 로그인 처리 - `GetUser()` - LDAP에서 사용자 조회 - `GetGroup()` - LDAP에서 그룹 조회 - `SyncAllUsers()` - 모든 사용자 동기화 - `RunTest()` - LDAP 연결 테스트 #### enterprise-impl/cluster/cluster.go Redis 기반 클러스터링 구현체입니다. 주요 메서드: - `StartInterNodeCommunication()` - 노드 간 통신 시작 - `RegisterClusterMessageHandler()` - 메시지 핸들러 등록 - `SendClusterMessage()` - 클러스터 메시지 전송 - `GetClusterStats()` - 클러스터 상태 조회 #### enterprise-impl/metrics/metrics.go Prometheus 메트릭 수집 구현체입니다. 주요 메서드: - `Register()` - 메트릭 등록 - `Handler()` - HTTP 핸들러 반환 - `IncrementHTTPRequest()` - HTTP 요청 카운트 - `ObserveAPIEndpointDuration()` - API 응답 시간 측정 ### 2. enterprise-community/ (등록 파일) #### enterprise-community/imports.go 모든 Enterprise 구현체를 임포트하여 init()이 실행되도록 합니다. ```go package enterprise_community import ( _ "github.com/mattermost/mattermost/server/v8/enterprise-community/ldap" _ "github.com/mattermost/mattermost/server/v8/enterprise-community/cluster" _ "github.com/mattermost/mattermost/server/v8/enterprise-community/metrics" // ... 기타 imports ) ``` #### enterprise-community/ldap/init.go LDAP 구현체를 app에 등록합니다. ```go package ldap import ( "github.com/mattermost/mattermost/server/v8/channels/app" ldapImpl "github.com/mattermost/mattermost/server/v8/enterprise-impl/ldap" ) func init() { app.RegisterLdapInterface(ldapImpl.New) } ``` ### 3. 수정된 파일 #### channels/api4/ldap.go LDAP 관련 API에서 라이선스 체크 제거: - `syncLdap()` - LDAP 동기화 - `testLdap()` - LDAP 연결 테스트 - `getLdapGroups()` - LDAP 그룹 조회 - `linkLdapGroup()` - LDAP 그룹 연결 - `unlinkLdapGroup()` - LDAP 그룹 연결 해제 - `migrateIdLdap()` - LDAP ID 마이그레이션 - `createLdapPublicCertificate()` - 인증서 생성 #### channels/api4/scheme.go 커스텀 권한 스키마 API에서 라이선스 체크 제거: - `createScheme()` - 스키마 생성 - `patchScheme()` - 스키마 수정 - `deleteScheme()` - 스키마 삭제 #### channels/api4/group.go 그룹 관련 API에서 라이선스 체크 제거: - `getGroupsByTeam()` - 팀별 그룹 조회 - `getGroupsByChannel()` - 채널별 그룹 조회 #### channels/api4/user.go 사용자 마이그레이션 API에서 라이선스 체크 제거: - `migrateAuthToLdap()` - LDAP 인증 마이그레이션 - `migrateAuthToSaml()` - SAML 인증 마이그레이션 #### channels/app/platform/metrics.go 메트릭 라우터에 `/metrics` 핸들러 등록 추가: ```go // MetricsHandlerProvider 인터페이스 추가 type MetricsHandlerProvider interface { Handler() http.Handler } // initMetricsRouter()에 핸들러 등록 코드 추가 if pm.metricsImpl != nil { if handlerProvider, ok := pm.metricsImpl.(MetricsHandlerProvider); ok { pm.router.Handle("/metrics", handlerProvider.Handler()) } } ``` --- ## 버전 업그레이드 가이드 Mattermost 새 버전으로 업그레이드할 때 다음 파일들을 이식해야 합니다. ### 필수 이식 파일 1. **enterprise-impl/ 전체 디렉토리** - 새 버전의 einterfaces에 맞게 수정 필요 - 인터페이스 변경 시 구현체 업데이트 2. **enterprise-community/ 전체 디렉토리** - 새로운 Enterprise 기능 추가 시 init 파일 추가 - app 패키지 경로 변경 시 import 수정 3. **enterprise/community_imports.go** - enterprise-community 패키지 임포트 유지 ### API 라이선스 체크 재제거 새 버전에서 다음 파일들의 라이선스 체크를 다시 제거해야 합니다: 1. **channels/api4/ldap.go** - `c.App.Channels().License() == nil` 조건문 찾아서 제거 - `!*c.App.Channels().License().Features.LDAP` 조건 제거 2. **channels/api4/scheme.go** - `!*c.App.Channels().License().Features.CustomPermissionsSchemes` 조건 제거 3. **channels/api4/group.go** - `!*c.App.Channels().License().Features.LDAPGroups` 조건 제거 4. **channels/api4/user.go** - LDAP/SAML 마이그레이션 라이선스 체크 제거 5. **channels/app/platform/metrics.go** - `MetricsHandlerProvider` 인터페이스 추가 - `/metrics` 핸들러 등록 코드 추가 ### 이식 스크립트 예시 ```bash #!/bin/bash # upgrade-mattermost.sh NEW_VERSION=$1 OLD_DIR="mattermost-community-enterprise" NEW_DIR="mattermost-server-$NEW_VERSION" # 1. 새 버전 다운로드 git clone https://github.com/mattermost/mattermost.git $NEW_DIR cd $NEW_DIR/server # 2. Enterprise 구현체 복사 cp -r $OLD_DIR/enterprise-impl ./ cp -r $OLD_DIR/enterprise-community ./ # 3. community_imports.go 복사 cp $OLD_DIR/enterprise/community_imports.go ./enterprise/ # 4. go.mod 업데이트 (enterprise-impl 추가) echo 'replace github.com/mattermost/mattermost/server/v8/enterprise-impl => ./enterprise-impl' >> go.mod # 5. vendor 업데이트 go mod vendor echo "이제 API 파일에서 라이선스 체크를 수동으로 제거하세요" ``` ### 라이선스 체크 자동 제거 스크립트 ```bash #!/bin/bash # remove-license-checks.sh # LDAP 라이선스 체크 제거 sed -i '/c\.App\.Channels()\.License() == nil.*LDAP/d' channels/api4/ldap.go sed -i '/!.*License()\.Features\.LDAP/d' channels/api4/ldap.go # Scheme 라이선스 체크 제거 sed -i '/License()\.Features\.CustomPermissionsSchemes/d' channels/api4/scheme.go # Group 라이선스 체크 제거 sed -i '/License()\.Features\.LDAPGroups/d' channels/api4/group.go echo "라이선스 체크 제거 완료. 빌드 테스트를 실행하세요." ``` --- ## einterfaces 매핑 | 인터페이스 | 구현 파일 | 등록 함수 | |-----------|----------|----------| | LdapInterface | enterprise-impl/ldap/ldap.go | app.RegisterLdapInterface | | SamlInterface | enterprise-impl/saml/saml.go | app.RegisterSamlInterface | | ClusterInterface | enterprise-impl/cluster/cluster.go | app.RegisterClusterInterface | | MetricsInterface | enterprise-impl/metrics/metrics.go | app.RegisterMetricsInterface | | ComplianceInterface | enterprise-impl/compliance/compliance.go | app.RegisterComplianceInterface | | DataRetentionInterface | enterprise-impl/data_retention/data_retention.go | app.RegisterDataRetentionInterface | | MessageExportInterface | enterprise-impl/message_export/message_export.go | app.RegisterMessageExportInterface | | AccountMigrationInterface | enterprise-impl/account_migration/account_migration.go | app.RegisterAccountMigrationInterface | --- ## 주의사항 1. **UI 라이선스 체크**: 웹 클라이언트(client/ 디렉토리)에도 라이선스 체크가 있을 수 있습니다. JavaScript 파일은 minified 상태라 수정이 어렵습니다. 2. **버전 호환성**: 이 구현체는 Mattermost v9.x를 기준으로 작성되었습니다. 메이저 버전이 변경되면 인터페이스 시그니처가 달라질 수 있습니다. 3. **테스트**: 업그레이드 후 반드시 모든 Enterprise 기능을 테스트하세요: - LDAP 로그인 - 클러스터 동기화 - Prometheus 메트릭 (/metrics 엔드포인트) - 커스텀 권한 스키마 생성/수정 4. **상용 사용**: 이 프로젝트는 학습 및 개인 사용 목적입니다. 상용 환경에서는 Mattermost 공식 라이선스를 구매하세요.