@@ -9,7 +9,10 @@ set (ENABLE_SSL AUTO CACHE STRING
9
9
case-sensitive. The default is \" AUTO\" . Note\ that SCRAM-SHA-1 is
10
10
required for authenticating to MongoDB 3.0 and later." )
11
11
12
- option (ENABLE_SASL "Use Cyrus SASL library for Kerberos." ON )
12
+ set (ENABLE_SASL AUTO CACHE STRING
13
+ "Enable SASL authentication (Kerberos).\ Options are \" CYRUS\" to use Cyrus
14
+ SASL, \" SSPI\" to use Windows Native SSPI, \" AUTO\" ,\ or \" OFF\" . These
15
+ options are case-sensitive." )
13
16
option (ENABLE_TESTS "Build MongoDB C Driver tests." ON )
14
17
option (ENABLE_EXAMPLES "Build MongoDB C Driver examples." ON )
15
18
option (ENABLE_AUTOMATIC_INIT_AND_CLEANUP "Enable automatic init and cleanup (GCC only)" ON )
@@ -118,15 +121,35 @@ if (ENABLE_CRYPTO_SYSTEM_PROFILE)
118
121
endif ()
119
122
endif ()
120
123
121
- if (ENABLE_SASL )
122
- include (FindSASL2 )
123
- endif ()
124
- if (ENABLE_SASL AND SASL2_FOUND )
125
- set (MONGOC_ENABLE_SASL 1 )
124
+ if (NOT (ENABLE_SASL STREQUAL CYRUS
125
+ OR ENABLE_SASL STREQUAL SSPI
126
+ OR ENABLE_SASL STREQUAL AUTO
127
+ OR ENABLE_SASL STREQUAL OFF ))
128
+ message (FATAL_ERROR
129
+ "ENABLE_SASL option must be CYRUS, SSPI, AUTO, or OFF" )
130
+ endif ()
131
+
132
+ set (MONGOC_HAVE_SASL_CLIENT_DONE 0 )
133
+ if (NOT ENABLE_SASL STREQUAL OFF )
134
+ if (ENABLE_SASL STREQUAL AUTO OR ENABLE_SASL STREQUAL CYRUS )
135
+ include (FindSASL2 )
136
+ endif ()
137
+
138
+ if (SASL2_FOUND )
139
+ set (MONGOC_ENABLE_SASL 1 )
140
+ set (MONGOC_ENABLE_SASL_CYRUS 1 )
141
+ set (MONGOC_ENABLE_SASL_SSPI 0 )
142
+ else ((ENABLE_SASL STREQUAL SSPI OR ENABLE_SASL STREQUAL AUTO ) AND WIN32 )
143
+ set (MONGOC_ENABLE_SASL 1 )
144
+ set (MONGOC_ENABLE_SASL_CYRUS 0 )
145
+ set (MONGOC_ENABLE_SASL_SSPI 1 )
146
+ endif ()
126
147
else ()
127
- set (MONGOC_HAVE_SASL_CLIENT_DONE 0 )
128
148
set (MONGOC_ENABLE_SASL 0 )
129
- endif ()
149
+ set (MONGOC_ENABLE_SASL_CYRUS 0 )
150
+ set (MONGOC_ENABLE_SASL_SSPI 0 )
151
+ endif ()
152
+
130
153
131
154
if (ENABLE_AUTOMATIC_INIT_AND_CLEANUP )
132
155
set (MONGOC_NO_AUTOMATIC_GLOBALS 0 )
@@ -380,9 +403,18 @@ endif () # ENABLE_SSL
380
403
381
404
382
405
if (MONGOC_ENABLE_SASL )
383
- set (SOURCES ${SOURCES} ${SOURCE_DIR} /src/mongoc/mongoc-sasl.c )
384
- set (LIBS ${LIBS} ${SASL2_LIBRARY} )
385
- include_directories (${SASL2_INCLUDE_DIR} )
406
+ set (SOURCES ${SOURCES} ${SOURCE_DIR} /src/mongoc/mongoc-cluster-sasl.c )
407
+ if (MONGOC_ENABLE_SASL_CYRUS )
408
+ message (STATUS "Compiling against Cyrus SASL" )
409
+ set (SOURCES ${SOURCES} ${SOURCE_DIR} /src/mongoc/mongoc-sasl.c )
410
+ set (LIBS ${LIBS} ${SASL2_LIBRARY} )
411
+ include_directories (${SASL2_INCLUDE_DIR} )
412
+ elseif (MONGOC_ENABLE_SASL_SSPI )
413
+ message (STATUS "Compiling against Windows SSPI" )
414
+ set (SOURCES ${SOURCES} ${SOURCE_DIR} /src/mongoc/mongoc-cluster-sspi.c )
415
+ set (SOURCES ${SOURCES} ${SOURCE_DIR} /src/mongoc/mongoc-sspi.c )
416
+ set (LIBS ${LIBS} secur32.lib crypt32.lib Shlwapi.lib )
417
+ endif ()
386
418
endif ()
387
419
388
420
add_library (mongoc_shared SHARED ${SOURCES} ${HEADERS} )
0 commit comments