Apache HTTPD
mod_authz_user.c
Go to the documentation of this file.
1/* Licensed to the Apache Software Foundation (ASF) under one or more
2 * contributor license agreements. See the NOTICE file distributed with
3 * this work for additional information regarding copyright ownership.
4 * The ASF licenses this file to You under the Apache License, Version 2.0
5 * (the "License"); you may not use this file except in compliance with
6 * the License. You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#include "apr_strings.h"
18
19#include "ap_config.h"
20#include "ap_provider.h"
21#include "httpd.h"
22#include "http_config.h"
23#include "http_core.h"
24#include "http_log.h"
25#include "http_protocol.h"
26#include "http_request.h"
27
28#include "mod_auth.h"
29
30typedef struct {
31 int dummy; /* just here to stop compiler warnings for now. */
33
35{
36 authz_user_config_rec *conf = apr_palloc(p, sizeof(*conf));
37
38 return conf;
39}
40
42{
43 {NULL}
44};
45
46module AP_MODULE_DECLARE_DATA authz_user_module;
47
49 const char *require_args,
50 const void *parsed_require_args)
51{
52 const char *err = NULL;
54 const char *require;
55
56 const char *t, *w;
57
58 if (!r->user) {
60 }
61
62 require = ap_expr_str_exec(r, expr, &err);
63 if (err) {
65 "authz_user authorize: require user: Can't "
66 "evaluate require expression: %s", err);
67 return AUTHZ_DENIED;
68 }
69
70 t = require;
71 while ((w = ap_getword_conf(r->pool, &t)) && w[0]) {
72 if (!strcmp(r->user, w)) {
73 return AUTHZ_GRANTED;
74 }
75 }
76
78 "access to %s failed, reason: user '%s' does not meet "
79 "'require'ments for user to be allowed access",
80 r->uri, r->user);
81
82 return AUTHZ_DENIED;
83}
84
86 const char *require_line,
87 const void *parsed_require_line)
88{
89 if (!r->user) {
91 }
92
93 return AUTHZ_GRANTED;
94}
95
96static const char *user_parse_config(cmd_parms *cmd, const char *require_line,
97 const void **parsed_require_line)
98{
99 const char *expr_err = NULL;
100 ap_expr_info_t *expr;
101
103 &expr_err, NULL);
104
105 if (expr_err)
106 return apr_pstrcat(cmd->temp_pool,
107 "Cannot parse expression in require line: ",
108 expr_err, NULL);
109
110 *parsed_require_line = expr;
111
112 return NULL;
113}
114
125
136
138{
140 create_authz_user_dir_config, /* dir config creater */
141 NULL, /* dir merger --- default is to override */
142 NULL, /* server config */
143 NULL, /* merge server config */
144 authz_user_cmds, /* command apr_table_t */
145 register_hooks /* register hooks */
146};
Symbol export macros and hook functions.
Apache Provider API.
apr_size_t const unsigned char unsigned int unsigned int d
Definition apr_siphash.h:72
APR Strings library.
#define AP_DECLARE_MODULE(foo)
request_rec * r
#define APLOGNO(n)
Definition http_log.h:117
#define ap_log_rerror
Definition http_log.h:454
#define APLOG_ERR
Definition http_log.h:67
#define APLOG_MARK
Definition http_log.h:283
#define APLOG_DEBUG
Definition http_log.h:71
apr_status_t ap_register_auth_provider(apr_pool_t *pool, const char *provider_group, const char *provider_name, const char *provider_version, const void *provider, int type)
Definition request.c:2179
#define AP_AUTH_INTERNAL_PER_CONF
#define AP_EXPR_FLAG_STRING_RESULT
Definition ap_expr.h:68
#define ap_expr_parse_cmd(cmd, expr, flags, err, lookup_fn)
Definition ap_expr.h:340
const char * ap_expr_str_exec(request_rec *r, const ap_expr_info_t *expr, const char **err)
#define STANDARD20_MODULE_STUFF
char * ap_getword_conf(apr_pool_t *p, const char **line)
Definition util.c:833
apr_size_t size
apr_interval_time_t t
apr_int32_t apr_int32_t apr_int32_t err
apr_cmdtype_e cmd
Apache Configuration.
CORE HTTP Daemon.
Apache Logging library.
HTTP protocol handling.
Apache Request library.
HTTP Daemon routines.
apr_pool_t * p
Definition md_event.c:32
Authentication and Authorization Extension for Apache.
authz_status
Definition mod_auth.h:72
@ AUTHZ_DENIED
Definition mod_auth.h:73
@ AUTHZ_DENIED_NO_USER
Definition mod_auth.h:77
@ AUTHZ_GRANTED
Definition mod_auth.h:74
#define AUTHZ_PROVIDER_VERSION
Definition mod_auth.h:42
#define AUTHZ_PROVIDER_GROUP
Definition mod_auth.h:40
static void * create_authz_user_dir_config(apr_pool_t *p, char *d)
static const authz_provider authz_validuser_provider
static const authz_provider authz_user_provider
static const command_rec authz_user_cmds[]
static void register_hooks(apr_pool_t *p)
static authz_status user_check_authorization(request_rec *r, const char *require_args, const void *parsed_require_args)
static authz_status validuser_check_authorization(request_rec *r, const char *require_line, const void *parsed_require_line)
static const char * user_parse_config(cmd_parms *cmd, const char *require_line, const void **parsed_require_line)
return NULL
Definition mod_so.c:359
A structure that represents the current request.
Definition httpd.h:845
char * user
Definition httpd.h:1005
char * uri
Definition httpd.h:1016
apr_pool_t * pool
Definition httpd.h:847
A structure to keep track of authorization requirements.
Definition http_core.h:316