mod_auth_digest.c revision 000b67449410515eac43e76ef6667915bfd4d2ab
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder/* ====================================================================
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * The Apache Software License, Version 1.1
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * Copyright (c) 2000 The Apache Software Foundation. All rights
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * Redistribution and use in source and binary forms, with or without
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * modification, are permitted provided that the following conditions
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * 1. Redistributions of source code must retain the above copyright
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * notice, this list of conditions and the following disclaimer.
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * 2. Redistributions in binary form must reproduce the above copyright
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * notice, this list of conditions and the following disclaimer in
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * the documentation and/or other materials provided with the
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * distribution.
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * 3. The end-user documentation included with the redistribution,
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * if any, must include the following acknowledgment:
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * "This product includes software developed by the
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * Apache Software Foundation (http://www.apache.org/)."
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * Alternately, this acknowledgment may appear in the software itself,
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * if and wherever such third-party acknowledgments normally appear.
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * 4. The names "Apache" and "Apache Software Foundation" must
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * not be used to endorse or promote products derived from this
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * software without prior written permission. For written
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * permission, please contact apache@apache.org.
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * 5. Products derived from this software may not be called "Apache",
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * nor may "Apache" appear in their name, without prior written
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * permission of the Apache Software Foundation.
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
806fd9e08b8b68eeeb0eccfd8892046a2985e594Christian Maeder * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
11ad38296d4182aac74ce6d5bef27911fbc9690dChristian Maeder * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* This module an updated version of modules/standard/mod_digest.c
#ifndef WIN32
#include "ap_config_auto.h"
#include "httpd.h"
#include "http_config.h"
#include "http_conf_globals.h"
#include "http_core.h"
#include "http_request.h"
#include "http_log.h"
#include "http_protocol.h"
#include "ap_ctype.h"
#include "util_uri.h"
#include "util_md5.h"
#include "ap_sha1.h"
#include "ap_base64.h"
#include "apr_time.h"
#include "apr_errno.h"
#include "apr_lock.h"
#include "apr_shmem.h"
typedef void ap_shmem_t;
typedef void ap_shm_name_t;
return APR_ENOTIMPL;
return APR_ENOTIMPL;
return NULL;
return NULL;
return APR_ENOTIMPL;
return APR_ENOTIMPL;
return APR_ENOTIMPL;
return APR_ENOTIMPL;
return APR_ENOTIMPL;
typedef struct digest_config_struct {
const char *dir_name;
const char *pwfile;
const char *grpfile;
const char *realm;
const char **qop_list;
const char *nonce_format;
int check_nc;
const char *algorithm;
char *uri_list;
const char *ha1;
typedef struct hash_entry {
} client_entry;
static struct hash_table {
unsigned long tbl_len;
unsigned long num_entries;
unsigned long num_created;
unsigned long num_removed;
unsigned long num_renewed;
} *client_list;
typedef struct digest_header_struct {
const char *scheme;
const char *realm;
const char *username;
char *nonce;
const char *uri;
const char *digest;
const char *algorithm;
const char *cnonce;
const char *opaque;
unsigned long opaque_num;
const char *message_qop;
const char *nonce_count;
const char *raw_request_uri;
int needed_auth;
typedef union time_union {
} time_rec;
static int call_cnt = 0;
static unsigned long *opaque_cntr;
if (client_shm) {
if (client_lock) {
if (opaque_lock) {
return APR_SUCCESS;
unsigned long idx;
if (!client_list) {
*otn_counter = 0;
#define APR_HAS_SHARED_MEMORY 0
initialize_tables(s, p);
if (!client_shm)
!= APR_SUCCESS
!= APR_SUCCESS) {
if (conf) {
return conf;
return DECLINE_CMD;
const char *file)
return NULL;
const char *file)
return NULL;
const char **tmp;
int cnt;
return NULL;
return NULL;
char *endptr;
long lifetime;
return NULL;
const char *fmt)
return NULL;
if (!client_shm) {
return NULL;
if (c->uri_list) {
return NULL;
const char *size_str)
char *endptr;
if (num_buckets == 0)
return NULL;
{NULL}
int bucket;
if (entry)
return entry;
static long gc(void)
num_removed++;
return num_removed;
server_rec *s)
int bucket;
if (!entry) {
return entry;
const char *auth_line;
size_t l;
if (!auth_line) {
return !OK;
return !OK;
vk = 0;
auth_line++;
vv = 0;
auth_line++;
return !OK;
return OK;
int res;
if (!ap_is_initial_req(r))
return DECLINED;
return DECLINED;
int idx;
if (opaque)
int len;
time_rec t;
else if (otn_counter)
return nonce;
unsigned long op;
return NULL;
return entry;
* people need not modify mod_auth_digest.c each time they install a new
int generate)
else if (!generate)
return NULL;
if (ha1)
return ha1;
return dir;
return "http://0.0.0.0/";
return dir;
return tmp;
if (num != 0)
int cnt;
if (opaque[0])
if (r->proxyreq)
configfile_t *f;
char l[MAX_STRING_LEN];
const char *rpw;
return NULL;
rpw = l;
ap_cfg_closefile(f);
ap_cfg_closefile(f);
return NULL;
unsigned long nc;
char *endptr;
return OK;
return !OK;
return !OK;
return !OK;
return OK;
double dt;
int len;
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return OK;
const char *ha2;
if (!ha1)
return NULL;
NULL));
request_rec *r) {
int res;
return DECLINED;
if (!ap_auth_name(r)) {
return HTTP_INTERNAL_SERVER_ERROR;
mainreq = r;
r->uri);
return HTTP_UNAUTHORIZED;
return HTTP_BAD_REQUEST;
return HTTP_BAD_REQUEST;
return HTTP_BAD_REQUEST;
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return DECLINED;
return HTTP_UNAUTHORIZED;
r->uri);
return HTTP_UNAUTHORIZED;
const char *exp_digest;
if (!match
return HTTP_UNAUTHORIZED;
if (!exp_digest) {
return HTTP_INTERNAL_SERVER_ERROR;
r->uri);
return HTTP_UNAUTHORIZED;
return HTTP_UNAUTHORIZED;
return res;
return OK;
const char *grpfile)
configfile_t *f;
char l[MAX_STRING_LEN];
return NULL;
return NULL;
ll = l;
while (ll[0]) {
ap_cfg_closefile(f);
return grps;
int m = r->method_number;
int method_restricted = 0;
return DECLINED;
if (!reqs_arr)
return OK;
return OK;
return OK;
if (!grpstatus)
return DECLINED;
return OK;
return DECLINED;
if (!method_restricted)
return OK;
return HTTP_UNAUTHORIZED;
#ifdef SEND_DIGEST
if (val)
return val;
return OK;
#ifdef SEND_DIGEST
char *entity_info =
date :
NULL));
digest =
NULL));
conf);
if (digest)
if (!ha1) {
return !OK;
NULL);
ai);
return OK;
static void register_hooks(void)