【问题标题】:Kerberos authentication does not work in Mongodb Enterprise 3.2Kerberos 身份验证在 Mongodb Enterprise 3.2 中不起作用
【发布时间】:2016-04-20 06:45:23
【问题描述】:

环境 Windows 2012 R2。 MongoDB Enterprise 3.2.0,这是一个评估版。

我以muser1 身份登录。 为什么要寻找字段密码? 我该如何解决?

c:\MongoDB\scripts>mongo.exe --authenticationMechanism=GSSAPI --authenticationDatabase='$external' --username muser1@TEST.MNG
MongoDB shell version: 3.2.0
connecting to: test
2016-01-14T14:03:37.572-0800 E QUERY    [thread1] Error: Missing expected field "pwd" :
DB.prototype._authOrThrow@src/mongo/shell/db.js:1395:16
@(auth):6:1
@(auth):1:2

exception: login failed

用户存在:

MongoDB Enterprise > user = db.system.users.findOne({user: "muser1@TEST.MNG"})

    {
            "_id" : "$external.muser1@TEST.MNG",
            "user" : "muser1@TEST.MNG",
            "db" : "$external",
            "credentials" : {
                    "external" : true
            },
            "roles" : [
                    {
                            "role" : "readWrite",
                            "db" : "test"
                    }
            ]
    }

根据 3.2 文档正确配置了 Kerberos。 DNS 配置正确。 MongoDB 服务正在使用域帐户运行。 SPN 用于默认服务和命名服务。尝试只配置其中一个,然后单独配置另一个,没有运气。

c:\MongoDB\scripts>setspn -L m1svr
Registered ServicePrincipalNames for CN=Mongo1,CN=Users,DC=test,DC=mng:
        mongodb/m1.test.mng
        MongoDB_M1_D1/m1.test.mng

这是启动配置文件:

# Data Node, with minimal oplog and no jurnal
net:
  port: 27017
systemLog:
  verbosity: '0'                    #Debug level from 0-5
  destination: file
  path: C:\MongoDB\logs\m1-d1.log 
  logAppend: false 

storage:
  dbPath: C:\MongoDB\data\m1\D1
  journal:
    enabled: false
  directoryPerDB : true 
  wiredTiger:
    engineConfig:
      cacheSizeGB: 1
      statisticsLogDelaySecs: 1
      journalCompressor: snappy
      directoryForIndexes: true
    collectionConfig:
      blockCompressor: snappy
    indexConfig:
      prefixCompression: true

#replication:
#   oplogSizeMB: 10
#   replSetName: RSTest

security:
  authorization: enabled
#  sasl:
#    hostName: m1.test.mng
#    serviceName: MongoDB_M1_D1
#  keyFile: F:\config\key1.txt
#  clusterAuthMode: keyFile

setParameter:
  authenticationMechanisms: GSSAPI,SCRAM-SHA-1

我尝试在用户文档中添加一个密码字段(以防万一),但没有成功。 我没有想法。

【问题讨论】:

  • 您解决了这个问题吗?
  • 否,删除了测试虚拟机,移动到不同的 NoSQL 数据库
  • 它要求在 shell 中输入 pwd 字段,因为您还提供了用户名。在 GSSAPI 的情况下,您不需要提供用户名或密码......凭据将来自进程的所有者。在大多数情况下,这是登录用户。

标签: mongodb authentication authorization kerberos enterprise


【解决方案1】:

使用 Kerberos 身份验证时,您需要为要连接的服务器定义完全限定的域名作为连接字符串的一部分。请注意,域部分也需要全部大写。例如:

mongo.exe --host servername.TEST.MNG --authenticationMechanism=GSSAPI --authenticationDatabase='$external' --username muser1@TEST.MNG

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-10-31
    • 1970-01-01
    • 2015-06-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多