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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
17 #include "apr_strings.h"
19 #include "ap_config.h"
20 #include "ap_provider.h"
22 #include "http_config.h"
23 #include "http_core.h"
25 #include "http_protocol.h"
26 #include "http_request.h"
31 int dummy
; /* just here to stop compiler warnings for now. */
32 } authz_user_config_rec
;
34 static void *create_authz_user_dir_config(apr_pool_t
*p
, char *d
)
36 authz_user_config_rec
*conf
= apr_palloc(p
, sizeof(*conf
));
41 static const command_rec authz_user_cmds
[] =
46 module AP_MODULE_DECLARE_DATA authz_user_module
;
48 static authz_status
user_check_authorization(request_rec
*r
,
49 const char *require_args
)
54 ap_log_rerror(APLOG_MARK
, APLOG_ERR
, 0, r
,
55 "access to %s failed, reason: no authenticated user", r
->uri
);
60 while ((w
= ap_getword_conf(r
->pool
, &t
)) && w
[0]) {
61 if (!strcmp(r
->user
, w
)) {
66 ap_log_rerror(APLOG_MARK
, APLOG_ERR
, 0, r
,
67 "access to %s failed, reason: user '%s' does not meet "
68 "'require'ments for user to be allowed access",
74 static authz_status
validuser_check_authorization(request_rec
*r
, const char *require_line
)
77 ap_log_rerror(APLOG_MARK
, APLOG_ERR
, 0, r
,
78 "access to %s failed, reason: no authenticated user", r
->uri
);
85 static const authz_provider authz_user_provider
=
87 &user_check_authorization
,
89 static const authz_provider authz_validuser_provider
=
91 &validuser_check_authorization
,
94 static void register_hooks(apr_pool_t
*p
)
96 ap_register_auth_provider(p
, AUTHZ_PROVIDER_GROUP
, "user",
97 AUTHZ_PROVIDER_VERSION
,
98 &authz_user_provider
, AP_AUTH_INTERNAL_PER_CONF
);
99 ap_register_auth_provider(p
, AUTHZ_PROVIDER_GROUP
, "valid-user",
100 AUTHZ_PROVIDER_VERSION
,
101 &authz_validuser_provider
,
102 AP_AUTH_INTERNAL_PER_CONF
);
105 module AP_MODULE_DECLARE_DATA authz_user_module
=
107 STANDARD20_MODULE_STUFF
,
108 create_authz_user_dir_config
, /* dir config creater */
109 NULL
, /* dir merger --- default is to override */
110 NULL
, /* server config */
111 NULL
, /* merge server config */
112 authz_user_cmds
, /* command apr_table_t */
113 register_hooks
/* register hooks */