-
Notifications
You must be signed in to change notification settings - Fork 9
/
mod_ucam_none.c
101 lines (69 loc) · 2.99 KB
/
mod_ucam_none.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
This file is part of the University of Cambridge Web Authentication
System Application Agent for Apache 2
See http://raven.cam.ac.uk/ for more details
Copyright (c) University of Cambridge 2005
This application agent is free software; you can redistribute it
and/or modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The agent 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this toolkit; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
USA
Author: Jon Warbrick <jw35@cam.ac.uk>
*/
#define VERSION "0.0.1"
#include <string.h>
#include "httpd.h"
#include "http_config.h"
#include "http_core.h"
#include "http_log.h"
/* logging macro. Note that it will only work in an environment where
'r' holds a copy of the current request record */
#define APACHE_LOG0(level, fmt) \
ap_log_rerror(APLOG_MARK, level, 0, r, fmt)
#define APACHE_LOG1(level, fmt, a) \
ap_log_rerror(APLOG_MARK, level, 0, r, fmt, a)
#define APACHE_LOG2(level, fmt, a, b) \
ap_log_rerror(APLOG_MARK, level, 0, r, fmt, a, b)
/* ---------------------------------------------------------------------- */
/* Standard forward declaration of the module structure since
_something_ is bound to need it before it's defined at the end */
module AP_MODULE_DECLARE_DATA ucam_none_module;
/* Auth handler */
static int
none_authn(request_rec *r)
{
const char *t;
if (!(t = ap_auth_type(r)) || strcasecmp(t, "None")) {
APACHE_LOG2
(APLOG_DEBUG,"mod_ucam_none declining authn for %s (AuthType = %s)",
r->uri, ap_auth_type(r) == NULL ? "(null)" : ap_auth_type(r));
return DECLINED;
}
APACHE_LOG1(APLOG_DEBUG,"mod_ucam_none accepting authn for %s ", r->uri);
r->user = "nobody";
r->ap_auth_type = "None";
return OK;
}
/* ---------------------------------------------------------------------- */
/* make Apache aware of the handlers */
static void none_register_hooks(apr_pool_t *p) {
ap_hook_check_user_id
(none_authn, NULL, NULL, APR_HOOK_MIDDLE);
}
module AP_MODULE_DECLARE_DATA ucam_none_module = {
STANDARD20_MODULE_STUFF,
NULL, /* create per-directory config structures */
NULL, /* merge per-directory config structures */
NULL, /* create per-server config structures */
NULL, /* merge per-server config structures */
NULL, /* command handlers */
none_register_hooks /* register hooks */
};
/* ---------------------------------------------------------------------- */