Explorar o código

Add define to disable OAuth support (#1713)

Redoing https://github.com/coturn/coturn/pull/1664 as requested. This
adds an optional OAUTH_DISABLED define to allow for disabling OAuth
support.
Shane hai 3 meses
pai
achega
2944775261
Modificáronse 3 ficheiros con 30 adicións e 1 borrados
  1. 3 0
      CMakeLists.txt
  2. 8 1
      configure
  3. 19 0
      src/client/ns_turn_msg.c

+ 3 - 0
CMakeLists.txt

@@ -111,6 +111,9 @@ if (BUILD_SHARED_LIBS)
     set(CMAKE_POSITION_INDEPENDENT_CODE ON)
 endif(BUILD_SHARED_LIBS)
 
+# Uncomment to disable OAuth support
+#add_definitions(-DTURN_NO_OAUTH)
+
 include(CMakePackageConfigHelpers)
 include(GNUInstallDirs)
 include(GenerateExportHeader)

+ 8 - 1
configure

@@ -1022,11 +1022,18 @@ if [ -n "${TURN_NO_TLS}" ]; then
     TURN_NO_TLS="-DTURN_NO_TLS"
 fi
 
+###############################
+# OAUTH
+###############################
+
+# Uncomment to disable OAuth support
+#TURN_NO_OAUTH="-DTURN_NO_OAUTH"
+
 ###############################
 # So, what we have now:
 ###############################
 
-OSCFLAGS="${OSCFLAGS} ${TURN_NO_SCTP} ${TURN_SCTP_INCLUDE} ${TURN_NO_THREAD_BARRIERS} ${TURN_NO_DTLS} ${TURN_NO_GCM} ${TURN_NO_TLS} -DINSTALL_PREFIX=${PREFIX} -DTURNDB=${TURNDBDIR}/turndb"
+OSCFLAGS="${OSCFLAGS} ${TURN_NO_SCTP} ${TURN_SCTP_INCLUDE} ${TURN_NO_THREAD_BARRIERS} ${TURN_NO_DTLS} ${TURN_NO_GCM} ${TURN_NO_TLS} -DINSTALL_PREFIX=${PREFIX} -DTURNDB=${TURNDBDIR}/turndb ${TURN_NO_OAUTH}"
 
 if ! [ -z "${TURN_ACCEPT_RPATH}" ] ; then
   if [ -z "${TURN_DISABLE_RPATH}" ] ; then

+ 19 - 0
src/client/ns_turn_msg.c

@@ -2078,6 +2078,7 @@ static bool calculate_key(char *key, size_t key_size, char *new_key, size_t new_
 }
 
 bool convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *err_msg, size_t err_msg_size) {
+#if !defined(TURN_NO_OAUTH)
   if (oakd0 && key) {
 
     oauth_key_data oakd_obj;
@@ -2159,8 +2160,14 @@ bool convert_oauth_key_data(const oauth_key_data *oakd0, oauth_key *key, char *e
   }
 
   return true;
+#else
+  OAUTH_ERROR("Oauth support not included");
+  return false;
+#endif
 }
 
+#if !defined(TURN_NO_OAUTH)
+
 const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg);
 const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg) {
   switch (enc_alg) {
@@ -2424,8 +2431,11 @@ static bool decode_oauth_token_gcm(const uint8_t *server_name, const encoded_oau
 
 #endif
 
+#endif
+
 bool encode_oauth_token(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key,
                         const oauth_token *dtoken, const uint8_t *nonce) {
+#if !defined(TURN_NO_OAUTH)
   UNUSED_ARG(nonce);
   if (server_name && etoken && key && dtoken) {
     switch (key->as_rs_alg) {
@@ -2440,10 +2450,15 @@ bool encode_oauth_token(const uint8_t *server_name, encoded_oauth_token *etoken,
     };
   }
   return false;
+#else
+  OAUTH_ERROR("Oauth support not included");
+  return false;
+#endif
 }
 
 bool decode_oauth_token(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key,
                         oauth_token *dtoken) {
+#if !defined(TURN_NO_OAUTH)
   if (server_name && etoken && key && dtoken) {
     switch (key->as_rs_alg) {
 #if !defined(TURN_NO_GCM)
@@ -2457,6 +2472,10 @@ bool decode_oauth_token(const uint8_t *server_name, const encoded_oauth_token *e
     };
   }
   return false;
+#else
+  OAUTH_ERROR("Oauth support not included");
+  return false;
+#endif
 }
 
 ///////////////////////////////////////////////////////////////