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.
This commit is contained in:
Shane 2025-07-02 02:36:50 -07:00 committed by GitHub
parent 0f8cdde961
commit 2944775261
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 30 additions and 1 deletions

View File

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

9
configure vendored
View File

@ -1022,11 +1022,18 @@ if [ -n "${TURN_NO_TLS}" ]; then
TURN_NO_TLS="-DTURN_NO_TLS" TURN_NO_TLS="-DTURN_NO_TLS"
fi fi
###############################
# OAUTH
###############################
# Uncomment to disable OAuth support
#TURN_NO_OAUTH="-DTURN_NO_OAUTH"
############################### ###############################
# So, what we have now: # 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_ACCEPT_RPATH}" ] ; then
if [ -z "${TURN_DISABLE_RPATH}" ] ; then if [ -z "${TURN_DISABLE_RPATH}" ] ; then

View File

@ -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) { 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) { if (oakd0 && key) {
oauth_key_data oakd_obj; 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; 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);
const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg) { const EVP_CIPHER *get_cipher_type(ENC_ALG enc_alg) {
switch (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
#endif
bool encode_oauth_token(const uint8_t *server_name, encoded_oauth_token *etoken, const oauth_key *key, 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) { const oauth_token *dtoken, const uint8_t *nonce) {
#if !defined(TURN_NO_OAUTH)
UNUSED_ARG(nonce); UNUSED_ARG(nonce);
if (server_name && etoken && key && dtoken) { if (server_name && etoken && key && dtoken) {
switch (key->as_rs_alg) { switch (key->as_rs_alg) {
@ -2440,10 +2450,15 @@ bool encode_oauth_token(const uint8_t *server_name, encoded_oauth_token *etoken,
}; };
} }
return false; 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, bool decode_oauth_token(const uint8_t *server_name, const encoded_oauth_token *etoken, const oauth_key *key,
oauth_token *dtoken) { oauth_token *dtoken) {
#if !defined(TURN_NO_OAUTH)
if (server_name && etoken && key && dtoken) { if (server_name && etoken && key && dtoken) {
switch (key->as_rs_alg) { switch (key->as_rs_alg) {
#if !defined(TURN_NO_GCM) #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; return false;
#else
OAUTH_ERROR("Oauth support not included");
return false;
#endif
} }
/////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////