/* * HttpAuth * * Copyright (C) 2004 Stefan Walter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * 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., * 59 Temple Place, Suite 330, * Boston, MA 02111-1307, USA. */ #ifndef BD_H #define BD_H #include "hash.h" #include "digest.h" #include "httpauthd.h" /* ---------------------------------------------------------------------------------- * Callbacks */ /* * A callback for completing a given user's digest ha1. In this function * you're required to fill in the digest ha1 hash for the user. ha1 will * always be an array of MD5_LEN bytes. * * Return Values * HA_OK: completed successfully * HA_FAILED: error retrieving hash (should have logged error) */ typedef int (*bd_validate_digest)(ha_request_t* rq, const char* user, digest_context_t* dg, char ***groups); /* * A callback for validating a given user's password. * * Return Values * HA_OK: good password * HA_FALSE: invalid password * HA_FAILED: error validating (should have logged error) */ typedef int (*bd_validate_basic) (ha_request_t *rq, const char *user, const char *password, char ***groups); /* * Escapes a value for sending to 'server' */ typedef void (*bd_escape_value)(const ha_request_t* rq, ha_buffer_t* buf, const char* value); /* ---------------------------------------------------------------------------------- * Base Context */ typedef struct bd_context { /* Readonly ---------------------------------------------*/ bd_validate_digest f_validate_digest; bd_validate_basic f_validate_basic; bd_escape_value f_escape_value; /* Require locking --------------------------------------*/ hsh_t* cache; /* Some cached records or basic */ unsigned int cache_max; /* Maximum number of records in cache */ } bd_context_t; #define BD_CALLBACKS(a, b, c) {(a), (b), (c), NULL } #define BD_DEFAULTS { NULL, NULL, NULL, NULL } /* ---------------------------------------------------------------------------------- * Base Handler Functions */ /* * The base/digest initialize function. Call this from your * 'derived' handler initialize function. */ int bd_init(ha_context_t* context); /* * The base/digest uninitialize function. Call this from your * 'derived' handler uninitialize function. */ void bd_destroy(ha_context_t* context); /* * The base/digest processer for requests. Call this from your * 'derived' handler process function. */ int bd_process(ha_request_t* rq); /* ---------------------------------------------------------------------------------- * Other helper functionts */ const char* bd_substitute(const ha_request_t* rq, const char* user, const char* str); #endif /* BD_H */