Apache2
mod_auth.h
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 
25 #ifndef APACHE_MOD_AUTH_H
26 #define APACHE_MOD_AUTH_H
27 
28 #include "apr_pools.h"
29 #include "apr_hash.h"
30 #include "apr_optional.h"
31 
32 #include "httpd.h"
33 #include "http_config.h"
34 
35 #ifdef __cplusplus
36 extern "C" {
37 #endif
38 
39 #define AUTHT_PROVIDER_GROUP "autht"
40 #define AUTHN_PROVIDER_GROUP "authn"
41 #define AUTHZ_PROVIDER_GROUP "authz"
42 #define AUTHT_PROVIDER_VERSION "0"
43 #define AUTHN_PROVIDER_VERSION "0"
44 #define AUTHZ_PROVIDER_VERSION "0"
45 #define AUTHT_DEFAULT_PROVIDER "jwt"
46 #define AUTHN_DEFAULT_PROVIDER "file"
47 
48 #define AUTHT_PROVIDER_NAME_NOTE "autht_provider_name"
49 #define AUTHN_PROVIDER_NAME_NOTE "authn_provider_name"
50 #define AUTHZ_PROVIDER_NAME_NOTE "authz_provider_name"
51 
52 #define AUTHT_PREFIX "TOKEN_"
53 #define AUTHN_PREFIX "AUTHENTICATE_"
54 #define AUTHZ_PREFIX "AUTHORIZE_"
55 
57 #ifndef SATISFY_ALL
58 #define SATISFY_ALL 0
59 #endif
61 #ifndef SATISFY_ANY
62 #define SATISFY_ANY 1
63 #endif
65 #ifndef SATISFY_NOSPEC
66 #define SATISFY_NOSPEC 2
67 #endif
68 
69 typedef enum {
77 
78 typedef enum {
86 
87 typedef enum {
92  AUTHZ_DENIED_NO_USER /* denied because r->user == NULL */
94 
95 typedef struct {
96  /* Given a username and password, expected to return AUTH_GRANTED
97  * if we can validate this user/password combination.
98  *
99  * Use with AUTHN_PROVIDER_VERSION / AUTHN_PROVIDER_VERSION1 providers.
100  */
101  authn_status (*check_password)(request_rec *r, const char *user,
102  const char *password);
103 
104  /* Given a user and realm, expected to return AUTH_USER_FOUND if we
105  * can find a md5 hash of 'user:realm:password'
106  *
107  * Use with AUTHN_PROVIDER_VERSION / AUTHN_PROVIDER_VERSION1 providers.
108  */
109  authn_status (*get_realm_hash)(request_rec *r, const char *user,
110  const char *realm, char **rethash);
111 
113 
114 /* A linked-list of authn providers. */
116 
118  const char *provider_name;
121 };
122 
123 typedef struct {
124  /* Given a token of a given type, expected to return AUTH_GRANTED
125  * if the token could be successfully authenticated.
126  */
127  autht_status (*check_token)(request_rec *r, const char *type,
128  const char *token);
129 
131 
132 /* A linked-list of authn providers. */
134 
136  const char *provider_name;
139 };
140 
141 typedef struct {
142  /* Given a request_rec, expected to return AUTHZ_GRANTED
143  * if we can authorize user access.
144  * @param r the request record
145  * @param require_line the argument to the authz provider
146  * @param parsed_require_line the value set by parse_require_line(), if any
147  */
148  authz_status (*check_authorization)(request_rec *r,
149  const char *require_line,
150  const void *parsed_require_line);
151 
159  const char *(*parse_require_line)(cmd_parms *cmd, const char *require_line,
160  const void **parsed_require_line);
162 
163 /* ap_authn_cache_store: Optional function for authn providers
164  * to enable caching their lookups with mod_authn_cache
165  * @param r The request rec
166  * @param module Module identifier
167  * @param user User name to authenticate
168  * @param realm Digest authn realm (NULL for basic authn)
169  * @param data The value looked up by the authn provider, to cache
170  */
172  (request_rec*, const char*, const char*,
173  const char*, const char*));
174 
175 #ifdef __cplusplus
176 }
177 #endif
178 
179 #endif
APR Hash Tables.
APR-UTIL registration of functions exported by modules.
APR memory allocation.
struct require_line require_line
Definition: http_core.h:311
#define APR_DECLARE_OPTIONAL_FN(ret, name, args)
Definition: apr_optional.h:50
request_rec * r
Definition: mod_dav.h:518
Apache Configuration.
HTTP Daemon routines.
autht_status
Definition: mod_auth.h:78
@ AUTHT_GENERAL_ERROR
Definition: mod_auth.h:81
@ AUTHT_DENIED
Definition: mod_auth.h:79
@ AUTHT_GRANTED
Definition: mod_auth.h:80
@ AUTHT_EXPIRED
Definition: mod_auth.h:83
@ AUTHT_MISMATCH
Definition: mod_auth.h:82
@ AUTHT_INVALID
Definition: mod_auth.h:84
authz_status
Definition: mod_auth.h:87
@ AUTHZ_DENIED
Definition: mod_auth.h:88
@ AUTHZ_GENERAL_ERROR
Definition: mod_auth.h:91
@ AUTHZ_DENIED_NO_USER
Definition: mod_auth.h:92
@ AUTHZ_NEUTRAL
Definition: mod_auth.h:90
@ AUTHZ_GRANTED
Definition: mod_auth.h:89
void ap_authn_cache_store(request_rec *, const char *, const char *, const char *, const char *)
authn_status
Definition: mod_auth.h:69
@ AUTH_GRANTED
Definition: mod_auth.h:71
@ AUTH_DENIED
Definition: mod_auth.h:70
@ AUTH_HANDLED
Definition: mod_auth.h:75
@ AUTH_USER_FOUND
Definition: mod_auth.h:72
@ AUTH_GENERAL_ERROR
Definition: mod_auth.h:74
@ AUTH_USER_NOT_FOUND
Definition: mod_auth.h:73
Definition: mod_auth.h:117
authn_provider_list * next
Definition: mod_auth.h:120
const authn_provider * provider
Definition: mod_auth.h:119
const char * provider_name
Definition: mod_auth.h:118
Definition: mod_auth.h:95
Definition: mod_auth.h:135
autht_provider_list * next
Definition: mod_auth.h:138
const autht_provider * provider
Definition: mod_auth.h:137
const char * provider_name
Definition: mod_auth.h:136
Definition: mod_auth.h:123
Definition: mod_auth.h:141
Definition: http_config.h:288
A structure that represents the current request.
Definition: httpd.h:856