Main Page | Modules | Namespace List | Class List | Directories | File List | Class Members | File Members | Related Pages | Examples

mod_authn_anon.c File Reference

#include "apr_strings.h"
#include "apr_want.h"
#include "ap_provider.h"
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
#include "http_request.h"
#include "http_protocol.h"
#include "mod_auth.h"

Go to the source code of this file.

Classes

struct  anon_auth_user
struct  authn_anon_config_rec

Defines

#define APR_WANT_STRFUNC

Typedefs

typedef anon_auth_user anon_auth_user

Functions

static void * create_authn_anon_dir_config (apr_pool_t *p, char *d)
static const char * anon_set_string_slots (cmd_parms *cmd, void *my_config, const char *arg)
static authn_status check_anonymous (request_rec *r, const char *user, const char *sent_pw)
static void register_hooks (apr_pool_t *p)

Variables

static const command_rec authn_anon_cmds []
module AP_MODULE_DECLARE_DATA authn_anon_module
static const authn_provider authn_anon_provider


Define Documentation

#define APR_WANT_STRFUNC
 

Definition at line 46 of file mod_authn_anon.c.


Typedef Documentation

typedef struct anon_auth_user anon_auth_user
 


Function Documentation

static const char* anon_set_string_slots cmd_parms cmd,
void *  my_config,
const char *  arg
[static]
 

Definition at line 88 of file mod_authn_anon.c.

References authn_anon_config_rec::anyuserid, conf, first, anon_auth_user::next, NULL, cmd_parms_struct::pool, anon_auth_user::user, and authn_anon_config_rec::users.

00090 {
00091     authn_anon_config_rec *conf = my_config;
00092     anon_auth_user *first;
00093 
00094     if (!*arg) {
00095         return "Anonymous string cannot be empty, use Anonymous_NoUserId";
00096     }
00097 
00098     /* squeeze in a record */
00099     if (!conf->anyuserid) {
00100         if (!strcmp(arg, "*")) {
00101             conf->anyuserid = 1;
00102         }
00103         else {
00104             first = conf->users;
00105             conf->users = apr_palloc(cmd->pool, sizeof(*conf->users));
00106             conf->users->user = apr_pstrdup(cmd->pool, arg);
00107             conf->users->next = first;
00108         }
00109     }
00110 
00111     return NULL;
00112 }

static authn_status check_anonymous request_rec r,
const char *  user,
const char *  sent_pw
[static]
 

Definition at line 135 of file mod_authn_anon.c.

References authn_anon_config_rec::anyuserid, ap_get_module_config, ap_strchr_c, APLOG_INFO, APLOG_MARK, APR_SUCCESS, AUTH_DENIED, AUTH_GRANTED, AUTH_USER_FOUND, AUTH_USER_NOT_FOUND, authn_anon_module, conf, authn_anon_config_rec::logemail, authn_anon_config_rec::mustemail, anon_auth_user::next, authn_anon_config_rec::nouserid, p, request_rec::per_dir_config, res, strcasecmp(), anon_auth_user::user, authn_anon_config_rec::users, and authn_anon_config_rec::verifyemail.

00137 {
00138     authn_anon_config_rec *conf = ap_get_module_config(r->per_dir_config,
00139                                                       &authn_anon_module);
00140     authn_status res = AUTH_USER_NOT_FOUND;
00141 
00142     /* Ignore if we are not configured */
00143     if (!conf->users && !conf->anyuserid) {
00144         return AUTH_USER_NOT_FOUND;
00145     }
00146 
00147     /* Do we allow an empty userID and/or is it the magic one
00148      */
00149     if (!*user) {
00150         if (conf->nouserid) {
00151             res = AUTH_USER_FOUND;
00152         }
00153     }
00154     else if (conf->anyuserid) {
00155         res = AUTH_USER_FOUND;
00156     }
00157     else {
00158         anon_auth_user *p = conf->users;
00159 
00160         while (p) {
00161             if (!strcasecmp(user, p->user)) {
00162                 res = AUTH_USER_FOUND;
00163                 break;
00164             }
00165             p = p->next;
00166         }
00167     }
00168 
00169     /* Now if the supplied user-ID was ok, grant access if:
00170      * (a) no passwd was sent and no password and no verification
00171      *     were configured.
00172      * (b) password was sent and no verification was configured
00173      * (c) verification was configured and the password (sent or not)
00174      *     looks like an email address
00175      */
00176     if (   (res == AUTH_USER_FOUND)
00177         && (!conf->mustemail || *sent_pw)
00178         && (   !conf->verifyemail
00179             || (ap_strchr_c(sent_pw, '@') && ap_strchr_c(sent_pw, '.'))))
00180     {
00181         if (conf->logemail && ap_is_initial_req(r)) {
00182             ap_log_rerror(APLOG_MARK, APLOG_INFO, APR_SUCCESS, r,
00183                           "Anonymous: Passwd <%s> Accepted",
00184                           sent_pw ? sent_pw : "\'none\'");
00185         }
00186 
00187         return AUTH_GRANTED;
00188     }
00189 
00190     return (res == AUTH_USER_NOT_FOUND ? res : AUTH_DENIED);
00191 }

static void* create_authn_anon_dir_config apr_pool_t p,
char *  d
[static]
 

Definition at line 73 of file mod_authn_anon.c.

References conf, and NULL.

00074 {
00075     authn_anon_config_rec *conf = apr_palloc(p, sizeof(*conf));
00076 
00077     /* just to illustrate the defaults really. */
00078     conf->users = NULL;
00079 
00080     conf->nouserid = 0;
00081     conf->anyuserid = 0;
00082     conf->logemail = 1;
00083     conf->verifyemail = 0;
00084     conf->mustemail = 1;
00085     return conf;
00086 }

static void register_hooks apr_pool_t p  )  [static]
 

Definition at line 199 of file mod_authn_anon.c.

References AUTHN_PROVIDER_GROUP.

00200 {
00201     ap_register_provider(p, AUTHN_PROVIDER_GROUP, "anon", "0",
00202                          &authn_anon_provider);
00203 }


Variable Documentation

const command_rec authn_anon_cmds[] [static]
 

Initial value:

{
    AP_INIT_ITERATE("Anonymous", anon_set_string_slots, NULL, OR_AUTHCFG,
     "a space-separated list of user IDs"),
    AP_INIT_FLAG("Anonymous_MustGiveEmail", ap_set_flag_slot,
     (void *)APR_OFFSETOF(authn_anon_config_rec, mustemail),
     OR_AUTHCFG, "Limited to 'on' or 'off'"),
    AP_INIT_FLAG("Anonymous_NoUserId", ap_set_flag_slot,
     (void *)APR_OFFSETOF(authn_anon_config_rec, nouserid),
     OR_AUTHCFG, "Limited to 'on' or 'off'"),
    AP_INIT_FLAG("Anonymous_VerifyEmail", ap_set_flag_slot,
     (void *)APR_OFFSETOF(authn_anon_config_rec, verifyemail),
     OR_AUTHCFG, "Limited to 'on' or 'off'"),
    AP_INIT_FLAG("Anonymous_LogEmail", ap_set_flag_slot,
     (void *)APR_OFFSETOF(authn_anon_config_rec, logemail),
     OR_AUTHCFG, "Limited to 'on' or 'off'"),
    {NULL}
}

Definition at line 114 of file mod_authn_anon.c.

module AP_MODULE_DECLARE_DATA authn_anon_module
 

Initial value:

Definition at line 205 of file mod_authn_anon.c.

Referenced by check_anonymous().

const authn_provider authn_anon_provider [static]
 

Initial value:

Definition at line 193 of file mod_authn_anon.c.


© sourcejam.com 2005-2008