ActiveDirectory와 함께 자체 관리형 SASL 및 LDAP 를 사용하여 인증
이 페이지의 내용
참고
MongoDB 8.0 부터 시작됩니다. LDAP 인증 및 권한 부여 는 더 이상 사용되지 않습니다. LDAP 는 사용할 수 있으며 MongoDB 8 의 수명 기간 동안 변경 없이 계속 작동합니다. LDAP 는 향후 주요 출시하다 에서 제거될 예정입니다.
자세한 내용은 LDAP 사용 중단을 참조하세요.
MongoDB Enterprise provides support for proxy authentication of users. This allows administrators to configure a MongoDB cluster to authenticate users by proxying authentication requests to a specified Lightweight Directory Access Protocol (LDAP) service.
참고
libldap
(예: RHEL에서 실행되는 경우) 에 연결된 MongoDB 4.2 엔터프라이즈 바이너리의 경우 libldap
액세스가 동기화되므로 일부 성능/대기 시간 비용이 발생합니다.
0}에 연결된 MongoDB 4.2 Enterprise 바이너리의 libldap_r
경우 이전 MongoDB 버전과 동작이 변경되지 않습니다.
고려 사항
경고
Windows용 MongoDB Enterprise는 saslauthd
를 통한 바인딩을 지원하지 않습니다.
Linux MongoDB 서버는
saslauthd
데몬을 통해 LDAP 서버에 대한 바인딩을 지원합니다.클라이언트와 서버,
saslauthd
서버와 LDAP 서버 간에는 암호화되거나 신뢰할 수 있는 보안 연결을 사용하세요. LDAP 서버는SASL PLAIN
메커니즘을 사용하여 일반 텍스트로 데이터를 보내고 받습니다. VPN과 같은 신뢰할 수 있는 채널, TLS/SSL로 암호화된 연결 또는 신뢰할 수 있는 유선 네트워크만 사용해야 합니다.
구성 saslauthd
LDAP support for user authentication requires proper configuration of
the saslauthd
daemon process as well as the MongoDB server.
Specify the mechanism.
On systems that configure saslauthd
with the
/etc/sysconfig/saslauthd
file, such as Red Hat Enterprise Linux,
Fedora, CentOS, and Amazon Linux AMI, set the mechanism MECH
to
ldap
:
MECH=ldap
On systems that configure saslauthd
with the
/etc/default/saslauthd
file, such as Ubuntu, set the MECHANISMS
option to ldap
:
MECHANISMS="ldap"
Adjust caching behavior.
On certain Linux distributions, saslauthd
starts with the caching
of authentication credentials enabled. Until restarted or until the
cache expires, saslauthd
will not contact the LDAP server to
re-authenticate users in its authentication cache. This allows
saslauthd
to successfully authenticate users in its cache, even in
the LDAP server is down or if the cached users' credentials are revoked.
To set the expiration time (in seconds) for the authentication cache, see
the -t option of
saslauthd
.
Configure LDAP Options with ActiveDirectory.
If the saslauthd.conf
file does not exist, create it.
The saslauthd.conf
file usually resides in the /etc
folder. If specifying a different file path, see the
-O option of
saslauthd
.
To use with ActiveDirectory, start saslauthd
with the following
configuration options set in the saslauthd.conf
file:
ldap_servers: <ldap uri> ldap_use_sasl: yes ldap_mech: DIGEST-MD5 ldap_auth_method: fastbind
For the <ldap uri>
, specify the uri of the ldap server. For
example, ldap_servers: ldaps://ad.example.net
.
For more information on saslauthd
configuration, see
http://www.openldap.org/doc/admin24/guide.html#Configuringsaslauthd.
Test the saslauthd
configuration.
다음을 사용하세요. testsaslauthd
utility to test the saslauthd
configuration. For example:
testsaslauthd -u testuser -p testpassword -f /var/run/saslauthd/mux
0: OK "Success"
indicates successful authentication.0: NO "authentication failed"
indicates a username, password, or configuration error.
Modify the file path with respect to the location of the
saslauthd
directory on the host operating system.
중요
security.sasl.saslauthdSocketPath
또는
--setParameter saslauthdPath
로 지정된 saslauthd
Unix 도메인 소켓 파일의 상위 디렉토리에 다음 대상에 대해 읽기 및 실행(
r-x
) 권한을 부여해야 합니다:
mongod
또는 mongos
는 saslauthd
디렉토리 및 해당 콘텐츠에 대해 지정된 권한이 없으면 saslauthd
를 통해 인증할 수 없습니다.
Configure MongoDB
Add user to MongoDB for authentication.
Add the user to the $external
database in MongoDB. To specify the
user's privileges, assign roles to the
user.
$external
인증 사용자(Kerberos, LDAP 또는 X.509 사용자)와 함께 클라이언트 세션 및 인과적 일관성 보장 을 사용하려면 사용자 이름이 10KB보다 클 수 없습니다.
For example, the following adds a user with read-only access to
the records
database.
db.getSiblingDB("$external").createUser( { user : <username>, roles: [ { role: "read", db: "records" } ] } )
Add additional principals as needed. For more information about creating and managing users, see 사용자 관리 명령.
Configure MongoDB server.
To configure the MongoDB server to use the saslauthd
instance for
proxy authentication, include the following options when starting mongod
:
--auth
command line option orsecurity.authorization
setting,authenticationMechanisms
parameter set toPLAIN
, andsaslauthdPath
parameter set to the path to the Unix-domain Socket of thesaslauthd
instance.중요
security.sasl.saslauthdSocketPath
또는
--setParameter saslauthdPath
로 지정된saslauthd
Unix 도메인 소켓 파일의 상위 디렉토리에 다음 대상에 대해 읽기 및 실행(
r-x
) 권한을 부여해야 합니다:mongod
또는mongos
는saslauthd
디렉토리 및 해당 콘텐츠에 대해 지정된 권한이 없으면saslauthd
를 통해 인증할 수 없습니다.
If you use the authorization
option to enforce
authentication, you will need privileges to create a user.
Use specific saslauthd
socket path.
For socket path of /<some>/<path>/saslauthd
, set the
saslauthdPath
to /<some>/<path>/saslauthd/mux
,
as in the following command line example:
mongod --auth --setParameter saslauthdPath=/<some>/<path>/saslauthd/mux --setParameter authenticationMechanisms=PLAIN
구성에 필요한 추가 옵션을 포함합니다. 예를 들어 원격 클라이언트를 배포에 연결하거나 배포 구성원이 다른 호스트에서 실행되도록 하려면 --bind_ip
를 지정합니다.
Or if using a YAML format configuration file, specify the following settings in the file:
security: authorization: enabled setParameter: saslauthdPath: /<some>/<path>/saslauthd/mux authenticationMechanisms: PLAIN
Or, if using the older configuration file format:
auth=true setParameter=saslauthdPath=/<some>/<path>/saslauthd/mux setParameter=authenticationMechanisms=PLAIN
Use default Unix-domain socket path.
To use the default Unix-domain socket path, set the
saslauthdPath
to the empty string ""
, as in the
following command line example:
mongod --auth --setParameter saslauthdPath="" --setParameter authenticationMechanisms=PLAIN
구성에 필요한 추가 옵션을 포함합니다. 예를 들어 원격 클라이언트를 배포에 연결하거나 배포 구성원이 다른 호스트에서 실행되도록 하려면 --bind_ip
를 지정합니다.
Or if using a YAML format configuration file, specify the following settings in the file:
security: authorization: enabled setParameter: saslauthdPath: "" authenticationMechanisms: PLAIN
Or, if using the older configuration file format:
auth=true setParameter=saslauthdPath="" setParameter=authenticationMechanisms=PLAIN
구성에 필요한 추가 옵션을 포함합니다. 예를 들어 원격 클라이언트가 배포에 연결하거나 배포 멤버가 다른 호스트에서 실행되도록 하려면 net.bindIp
설정을 지정하세요.
Authenticate the user in mongosh
.
You can authenticate from the command line during connection, or
connect first and then authenticate using db.auth()
method.
To authenticate when connecting with
mongosh
, run mongosh
with the following
command-line options, substituting <host>
and
<user>
, and enter your password when prompted:
mongosh --host <host> --authenticationMechanism PLAIN --authenticationDatabase '$external' -u <user> -p
Alternatively, connect without supplying credentials and then call
the db.auth()
method on the $external
database. Specify
the value "PLAIN"
in the mechanism
field, the user and
password in the user
and pwd
fields respectively. Use the default
digestPassword
value (false
) since the server must receive an
undigested password to forward on to saslauthd
, as in the
following example:
팁
메서드/명령 호출에서 암호를 직접 지정하는 대신 passwordPrompt()
메서드를 다양한 사용자 인증/관리 메서드/명령과 함께 사용하여 암호를 묻는 메시지를 표시할 수 있습니다. 그러나 이전 버전의 mongo
셸에서와 마찬가지로 비밀번호를 직접 지정할 수도 있습니다.
db.getSiblingDB("$external").auth( { mechanism: "PLAIN", user: <username>, pwd: passwordPrompt() // or cleartext password } )
메시지가 표시되면 비밀번호를 입력합니다.
The server forwards the password in plain text. In general, use only on a trusted channel (VPN, TLS/SSL, trusted wired network). See Considerations.