summaryrefslogtreecommitdiff
path: root/src/mongo/gotools/src/github.com/mongodb/mongo-tools/common/db/kerberos/gssapi.go
blob: 0e6d8b058b1f1b98be2da2d092b3263525c64aae (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 (
	"github.com/mongodb/mongo-tools/common/options"
	"gopkg.in/mgo.v2"
)

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
}