개요
일반 보안 서비스 API (GSSAPI) 인증 메커니즘 사용하면 주체 이름을 사용하여 Kerberos 서비스를 인증할 수 있습니다. 이 메커니즘은 MongoDB Enterprise Advanced 에 인증할 때만 사용할 수 있습니다.
Kerberos (GSSAPI) 인증 지정
참고
Node.js 드라이버는 UNIX에서는 MIT Kerberos 라이브러리를 사용하고 Windows에서는 SSPI API를 사용하여 Kerberos를 지원합니다.
GSSAPI 인증 메커니즘은 사용자 주체를 사용하여 Kerberos 서비스에 인증합니다.
연결 문자열 에옵션을 지정하는 동안 다음 작업을 수행하여 이 인증 메커니즘 지정할 수 있습니다.
authMechanism매개 변수를GSSAPI로 설정합니다.mongodb이외의 값을 사용하는 경우authMechanismProperties매개 변수에서SERVICE_NAME값을 설정합니다.사용자 지정 서비스 영역이 필요한 경우
authMechanismProperties매개 변수에SERVICE_REALM값을 지정합니다.호스트 이름의 정규화가 필요한 경우
authMechanismProperties매개변수에CANONICALIZE_HOST_NAME값을 지정합니다. 이 속성 다음 값을 사용할 수 있습니다.none: (기본값) 호스트 이름 정규화를 수행하지 않습니다.forward: 호스트 이름을 정규화하기 위해 정방향 DNS 조회를 수행합니다.forwardAndReverse: 정방향 DNS 조회를 수행한 다음 해당 값을 역방향 조회하여 호스트 이름을 정규화합니다.
중요
gssapiServiceName 매개변수는 더 이상 사용되지 않으며 이후 버전의 운전자 에서 제거될 수 있습니다. 대신 연결 URI에 authMechanismProperties=SERVICE_NAME:<your service name> 을(를) 사용하세요. 연결 문자열 의 인증 옵션에 대해 자세히 학습 서버 매뉴얼의 연결 문자열 옵션 레퍼런스에서 인증 옵션 섹션을 참조하세요.
다음 코드 예시 GSSAPI를 사용하여 UNIX용 Kerberos 에 인증합니다.
중요
항상 encodeURIComponent 메서드를 사용하여 주체를 URI로 인코딩 하여 올바르게 구문 분석되도록 합니다.
const { MongoClient } = require("mongodb"); // Replace the placeholder values with the values for your environment in the following lines const clusterUrl = "<cluster_url>"; const principal = encodeURIComponent("<Kerberos principal and realm>"); const serviceRealm = "<Kerberos service realm>"; const canonicalizationSetting = "<canonicalization setting>"; const authMechanismProperties = `SERVICE_REALM:${serviceRealm},CANONICALIZE_HOST_NAME:${canonicalizationSetting}`; const authMechanism = "GSSAPI"; // Connection URI const uri = `mongodb+srv://${principal}@${clusterUrl}/?authMechanism=${authMechanism}&authMechanismProperties=${authMechanismProperties}`; const client = new MongoClient(uri); // Function to connect to the server async function run() { try { // Establish and verify connection await client.db("admin").command({ ping: 1 }); console.log("Connected successfully to server"); } finally { // Ensures that the client will close when you finish/error await client.close(); } } run().catch(console.dir);
참고
운전자 SASL 메커니즘인 GSSAPI RFC-4652 를 통해 GSSAPI 인증하기 때문에 이 메서드는 대신 인증 메커니즘 참조합니다.Kerberos
API 문서
이 페이지에서 설명하는 메서드 또는 유형에 대해 자세히 학습 다음 API 설명서를 참조하세요.