Join us at MongoDB.local London on 7 May to unlock new possibilities for your data. Use WEB50 to save 50%.
Register now >
Docs Menu
Docs Home
/ /

SCRAM

SCRAM (Salted Challenge Response Authentication Mechanism)은 사용자 이름 과 비밀번호를 사용하여 서버 를 인증하는 인증 메커니즘 제품군입니다.

Rust 운전자 다음과 같은 SCRAM 기반 인증 메커니즘을 지원합니다:

  • SCRAM -SHA-:256 알고리즘 으로 암호화됨 데이터베이스 사용자 사용자 이름 과 비밀번호를 사용하는 인증 메커니즘 SHA-256 입니다. 이것이 기본값 인증 메커니즘 입니다.

  • SCRAM-SHA-1: SHA-1 알고리즘 으로 암호화됨 데이터베이스 사용자 사용자 이름 과 비밀번호를 사용하는 인증 메커니즘 입니다.

SCRAM 사용하여 MongoDB Atlas, MongoDB Enterprise Advanced 및 MongoDB Community Edition 에 인증할 수 있습니다.

SCRAM 메커니즘

SCRAM 인증 메커니즘 제품군에 대해 자세히 학습 Wikipedia의 RFC 5802Salted Challenge Response 인증 메커니즘 을 참조하세요.

SCRAM 의 MongoDB 구현 에 대한 자세한 내용은 MongoDB Server 매뉴얼의 SCRAM 참조하세요.

이 페이지의 코드 예제에서는 다음 자리 표시자를 사용합니다.

  • db_username: 데이터베이스 사용자 이름

  • db_password: 데이터베이스 비밀번호

  • db: 사용자와 연결된 인증 데이터베이스

SCRAM-SHA-256 이 기본값 인증 메커니즘 이므로 이 메커니즘을 사용하기 위해 Credential 구조체를 인스턴스화할 때 mechanism 필드 생략할 수 있습니다.

다음 예시 기본값 인증 메커니즘 지정합니다.

let uri = "<connection string>";
let mut client_options = ClientOptions::parse(uri).await?;
let default_cred = Credential::builder()
.username("<db_username>".to_string())
.password("<db_password>".to_string())
.source("<db>".to_string())
.build();
client_options.credential = Some(default_cred);
let client = Client::with_options(client_options)?;

SCRAM-SHA-256 인증 메커니즘 명시적으로 지정하려면 Credential 구조체의 mechanism 필드 AuthMechanism::ScramSha256로 설정하다 .

let uri = "<connection string>";
let mut client_options = ClientOptions::parse(uri).await?;
let scram_sha_256_cred = Credential::builder()
.username("<db_username>".to_string())
.password("<db_password>".to_string())
.mechanism(AuthMechanism::ScramSha256)
.source("<db>".to_string())
.build();
client_options.credential = Some(scram_sha_256_cred);
let client = Client::with_options(client_options)?;

SCRAM-SHA-1 인증 메커니즘 지정하려면 Credential 구조체의 mechanism 필드 AuthMechanism::ScramSha1로 설정하다 .

let uri = "<connection string>";
let mut client_options = ClientOptions::parse(uri).await?;
let scram_sha_1_cred = Credential::builder()
.username("<db_username>".to_string())
.password("<db_password>".to_string())
.mechanism(AuthMechanism::ScramSha1)
.source("<db>".to_string())
.build();
client_options.credential = Some(scram_sha_1_cred);
let client = Client::with_options(client_options)?;

MongoDB 인증에 대해 자세히 알아보려면 서버 매뉴얼의 인증을 참조하세요.

MongoDB deployment 사용자 관리에 대해 자세히 알아보려면 서버 매뉴얼의 사용자를 참조하세요.

이 가이드에서 사용되는 메서드 또는 유형에 대해 자세히 알아보려면 다음 API 문서를 참조하세요.

돌아가기

인증

이 페이지의 내용