1
0
Fork 0

Feature: Added auth backend "enforce_auth".

Closes: #2348
This commit is contained in:
Philipp Schafft 2019-01-16 14:11:03 +00:00
parent b5e721ebff
commit 001ac59127
4 changed files with 47 additions and 1 deletions

View File

@ -98,7 +98,8 @@ icecast_SOURCES = \
auth.c \
auth_htpasswd.c \
auth_anonymous.c \
auth_static.c
auth_static.c \
auth_enforce_auth.c
if HAVE_CURL
icecast_SOURCES += \

View File

@ -596,6 +596,10 @@ static int get_authenticator (auth_t *auth, config_options_t *options)
if (auth_get_static_auth(auth, options) < 0)
return -1;
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);

View File

@ -34,6 +34,7 @@
#define AUTH_TYPE_LEGACY_PASSWORD "legacy-password"
#define AUTH_TYPE_URL "url"
#define AUTH_TYPE_HTPASSWD "htpasswd"
#define AUTH_TYPE_ENFORCE_AUTH "enforce-auth"
#define MAX_ADMIN_COMMANDS 32
@ -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_url_auth(auth_t *authenticator, 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 */
void auth_initialise(void);

39
src/auth_enforce_auth.c Normal file
View File

@ -0,0 +1,39 @@
/* 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;
}