blob: 698d94f7da2afcf9fa91d679a44a673ecee84655 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
// Copyright (C) MongoDB, Inc. 2014-present.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License. You may obtain
// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
// Package kerberos implements authentication to MongoDB using kerberos
package kerberos
// #cgo windows CFLAGS: -Ic:/sasl/include
// #cgo windows LDFLAGS: -Lc:/sasl/lib
import (
mgo "github.com/10gen/llmgo"
"github.com/mongodb/mongo-tools/legacy/options"
)
const authMechanism = "GSSAPI"
func AddKerberosOpts(opts options.ToolOptions, dialInfo *mgo.DialInfo) {
if dialInfo == nil {
return
}
if opts.Kerberos == nil {
return
}
if opts.Auth == nil || (opts.Auth.Mechanism != authMechanism &&
dialInfo.Mechanism != authMechanism) {
return
}
dialInfo.Service = opts.Kerberos.Service
dialInfo.ServiceHost = opts.Kerberos.ServiceHost
dialInfo.Mechanism = authMechanism
}
|