Commit de3a0755 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Merge branch 'feature-auth-enforce-auth'

parents b5e721eb 001ac591
Pipeline #503 failed with stage
in 15 seconds
...@@ -98,7 +98,8 @@ icecast_SOURCES = \ ...@@ -98,7 +98,8 @@ icecast_SOURCES = \
auth.c \ auth.c \
auth_htpasswd.c \ auth_htpasswd.c \
auth_anonymous.c \ auth_anonymous.c \
auth_static.c auth_static.c \
auth_enforce_auth.c
if HAVE_CURL if HAVE_CURL
icecast_SOURCES += \ icecast_SOURCES += \
......
...@@ -596,6 +596,10 @@ static int get_authenticator (auth_t *auth, config_options_t *options) ...@@ -596,6 +596,10 @@ static int get_authenticator (auth_t *auth, config_options_t *options)
if (auth_get_static_auth(auth, options) < 0) if (auth_get_static_auth(auth, options) < 0)
return -1; return -1;
break; break;
} else if (strcmp(auth->type, AUTH_TYPE_ENFORCE_AUTH) == 0) {
if (auth_get_enforce_auth_auth(auth, options) < 0)
return -1;
break;
} }
ICECAST_LOG_ERROR("Unrecognised authenticator type: \"%s\"", auth->type); ICECAST_LOG_ERROR("Unrecognised authenticator type: \"%s\"", auth->type);
......
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
#define AUTH_TYPE_LEGACY_PASSWORD "legacy-password" #define AUTH_TYPE_LEGACY_PASSWORD "legacy-password"
#define AUTH_TYPE_URL "url" #define AUTH_TYPE_URL "url"
#define AUTH_TYPE_HTPASSWD "htpasswd" #define AUTH_TYPE_HTPASSWD "htpasswd"
#define AUTH_TYPE_ENFORCE_AUTH "enforce-auth"
#define MAX_ADMIN_COMMANDS 32 #define MAX_ADMIN_COMMANDS 32
...@@ -170,6 +171,7 @@ int auth_get_anonymous_auth(auth_t *auth, config_options_t *options); ...@@ -170,6 +171,7 @@ int auth_get_anonymous_auth(auth_t *auth, config_options_t *options);
int auth_get_static_auth(auth_t *auth, config_options_t *options); int auth_get_static_auth(auth_t *auth, config_options_t *options);
int auth_get_url_auth(auth_t *authenticator, config_options_t *options); int auth_get_url_auth(auth_t *authenticator, config_options_t *options);
int auth_get_htpasswd_auth(auth_t *auth, config_options_t *options); int auth_get_htpasswd_auth(auth_t *auth, config_options_t *options);
int auth_get_enforce_auth_auth(auth_t *auth, config_options_t *options);
/* prototypes for auth.c */ /* prototypes for auth.c */
void auth_initialise(void); void auth_initialise(void);
......
/* Icecast
*
* This program is distributed under the GNU General Public License, version 2.
* A copy of this license is included with this source.
*
* Copyright 2014-2019, Philipp "ph3-der-loewe" Schafft <lion@lion.leolix.org>,
*/
/**
* Client authentication functions
*/
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include "auth.h"
#include "client.h"
#include "logging.h"
#define CATMODULE "auth_enforce_auth"
static auth_result enforce_auth_auth(auth_client *auth_user)
{
client_t *client = auth_user->client;
if (client->password)
return AUTH_NOMATCH;
return AUTH_FAILED;
}
int auth_get_enforce_auth_auth(auth_t *authenticator, config_options_t *options)
{
(void)options;
authenticator->authenticate_client = enforce_auth_auth;
authenticator->immediate = 1;
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment