Skip to content

Commit

Permalink
Implements validator dummy. Validator dummy throws out validation, wh…
Browse files Browse the repository at this point in the history
…ich can only be passed by by actually entering

something in the username/password fields. Empty throws an authentication required.
  • Loading branch information
skinkie committed Oct 21, 2011
1 parent fc522d3 commit c5c0868
Show file tree
Hide file tree
Showing 6 changed files with 155 additions and 2 deletions.
3 changes: 2 additions & 1 deletion admin/consts.py
Expand Up @@ -86,7 +86,8 @@
('ldap', N_('LDAP server')),
('mysql', N_('MySQL server')),
('pam', N_('PAM')),
('authlist', N_('Fixed list'))
('authlist', N_('Fixed list')),
('dummy', N_('Dummy Authentication')),
]

VALIDATOR_METHODS = [
Expand Down
1 change: 1 addition & 0 deletions admin/plugins/Makefile.am
Expand Up @@ -12,6 +12,7 @@ custom_error.py \
dbslayer.py \
directory.py \
dirlist.py \
dummy.py \
empty_gif.py \
error_nn.py \
error_redir.py \
Expand Down
19 changes: 19 additions & 0 deletions cherokee/Makefile.am
Expand Up @@ -1231,6 +1231,23 @@ endif
endif


#
# Validator dummy
#
validator_dummy = \
validator_dummy.c \
validator_dummy.h

libplugin_dummy_la_LDFLAGS = $(module_ldflags)
libplugin_dummy_la_SOURCES = $(validator_dummy)

if STATIC_VALIDATOR_DUMMY
static_validator_dummy_src = $(validator_dummy)
else
dynamic_validator_dummy_lib = libplugin_dummy.la
endif


#
# Cryptor libssl
#
Expand Down Expand Up @@ -1621,6 +1638,7 @@ $(static_validator_htdigest_src) \
$(static_validator_htpasswd_src) \
$(static_validator_authlist_src) \
$(static_validator_mysql_src) \
$(static_validator_dummy_src) \
\
$(static_cryptor_libssl_src) \
\
Expand Down Expand Up @@ -1810,6 +1828,7 @@ $(dynamic_validator_htdigest_lib) \
$(dynamic_validator_htpasswd_lib) \
$(dynamic_validator_authlist_lib) \
$(dynamic_validator_mysql_lib) \
$(dynamic_validator_dummy_lib) \
$(dynamic_cryptor_libssl_lib) \
$(dynamic_balancer_round_robin_lib) \
$(dynamic_balancer_ip_hash_lib) \
Expand Down
79 changes: 79 additions & 0 deletions cherokee/validator_dummy.c
@@ -0,0 +1,79 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* Cherokee
*
* Authors:
* Alvaro Lopez Ortega <alvaro@alobbs.com>
*
* Copyright (C) 2001-2011 Alvaro Lopez Ortega
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/

#include "common-internal.h"
#include "validator_dummy.h"
#include "connection-protected.h"

/* Plug-in initialization
*/
PLUGIN_INFO_VALIDATOR_EASIEST_INIT (dummy, http_auth_basic);

ret_t
cherokee_validator_dummy_new (cherokee_validator_dummy_t **dummy, cherokee_module_props_t *props)
{

CHEROKEE_NEW_STRUCT (n, validator_dummy);

cherokee_validator_init_base (VALIDATOR(n), VALIDATOR_PROPS(props), PLUGIN_INFO_VALIDATOR_PTR(dummy));
VALIDATOR(n)->support = http_auth_basic;

VALIDATOR(n)->check = (validator_func_check_t) cherokee_validator_dummy_check;


/* Return obj
*/
*dummy = n;
return ret_ok;
}

ret_t
cherokee_validator_dummy_configure (cherokee_config_node_t *conf,
cherokee_server_t *srv,
cherokee_module_props_t **_props)
{
UNUSED(conf);
UNUSED(srv);

if(*_props == NULL) {
CHEROKEE_NEW_STRUCT (n, validator_dummy_props);

cherokee_validator_props_init_base (VALIDATOR_PROPS (n), MODULE_PROPS_FREE(cherokee_validator_props_free_base));

*_props = MODULE_PROPS (n);
}

return ret_ok;
}

ret_t
cherokee_validator_dummy_check (cherokee_validator_dummy_t *dummy, cherokee_connection_t *conn)
{
UNUSED(dummy);

if ((conn->validator->user.len > 0) || (conn->validator->passwd.len > 0))
return ret_ok;

return ret_deny;
}
52 changes: 52 additions & 0 deletions cherokee/validator_dummy.h
@@ -0,0 +1,52 @@
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */

/* Cherokee
*
* Authors:
* Alvaro Lopez Ortega <alvaro@alobbs.com>
*
* Copyright (C) 2001-2011 Alvaro Lopez Ortega
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of version 2 of the GNU General Public
* License as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
* 02110-1301, USA.
*/

#ifndef CHEROKEE_VALIDATOR_DUMMY_H
#define CHEROKEE_VALIDATOR_DUMMY_H

#include "validator.h"
#include "connection.h"

typedef struct {
cherokee_module_props_t base;
} cherokee_validator_dummy_props_t;

typedef struct {
cherokee_validator_t validator;
} cherokee_validator_dummy_t;

/* Validator
*/

ret_t cherokee_validator_dummy_new (cherokee_validator_dummy_t **dummy,
cherokee_module_props_t *props);

ret_t cherokee_validator_dummy_configure (cherokee_config_node_t *conf,
cherokee_server_t *srv,
cherokee_module_props_t **_props);

ret_t cherokee_validator_dummy_check (cherokee_validator_dummy_t *dummy,
cherokee_connection_t *conn);

#endif /* CHEROKEE_VALIDATOR_DUMMY_H */
3 changes: 2 additions & 1 deletion configure.in
Expand Up @@ -1447,7 +1447,7 @@ AC_ARG_ENABLE(static-module,

modules="error_redir error_nn server_info file dirlist cgi fcgi scgi uwsgi proxy redir common ssi secdownload empty_gif drop admin custom_error dbslayer streaming gzip deflate ncsa combined custom pam ldap mysql htpasswd plain htdigest authlist round_robin ip_hash failover directory extensions request header exists fullpath method from bind tls geoip url_arg v_or wildcard rehost target_ip evhost post_track post_report libssl render_rrd rrd not and or"

beta_modules="filetime tile sphinx"
beta_modules="filetime tile sphinx dummy"

# Include beta modules only when --enable-beta is provided
#
Expand Down Expand Up @@ -1551,6 +1551,7 @@ AM_CONDITIONAL(STATIC_VALIDATOR_HTPASSWD, grep htpasswd $conf_h >/dev/
AM_CONDITIONAL(STATIC_VALIDATOR_PLAIN, grep plain $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_HTDIGEST, grep htdigest $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_AUTHLIST, grep authlist $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_VALIDATOR_DUMMY, grep dummy $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_BALANCER_ROUND_ROBIN, grep round_robin $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_BALANCER_IP_HASH, grep ip_hash $conf_h >/dev/null)
AM_CONDITIONAL(STATIC_BALANCER_FAILOVER, grep failover $conf_h >/dev/null)
Expand Down

0 comments on commit c5c0868

Please sign in to comment.