From 2944775261abc124b261899c3e62b60d3007cb6d Mon Sep 17 00:00:00 2001 From: Shane Date: Wed, 2 Jul 2025 02:36:50 -0700 Subject: [PATCH] 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. --- CMakeLists.txt | 3 +++ configure | 9 ++++++++- src/client/ns_turn_msg.c | 19 +++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fbd0c2..77d9503 100644 --- a/CMakeLists.txt +++ b/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) diff --git a/configure b/configure index 2b011dd..afebf86 100755 --- a/configure +++ b/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 diff --git a/src/client/ns_turn_msg.c b/src/client/ns_turn_msg.c index b14ca28..b02189e 100644 --- a/src/client/ns_turn_msg.c +++ b/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 } ///////////////////////////////////////////////////////////////