39423f1975603b453fc3f25fc8cfc9838c8bf586
[mod_auth_kerb.cvs/.git] / mod_auth_gssweb.c
1 /*
2  * Copyright (c) 2012, 2013, 2014 JANET(UK)
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * 3. Neither the name of JANET(UK) nor the names of its contributors
17  *    may be used to endorse or promote products derived from this software
18  *    without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24  * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
25  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31  * OF THE POSSIBILITY OF SUCH DAMAGE.
32  *
33  * NOTE: Some code in this module was derived from code in
34  * mod_auth_gssapi.c which is copyrighted by CESNET.  See that file
35  * for full copyright details.
36  *
37  * NOTE: Portions of the code in this file were derived from example
38  * code distributed under the Apache 2.0 license:
39  *     http://www.apache.org/licenses/LICENSE-2.0
40  * 
41  * This module implements the Apache server side of the GSSWeb
42  * authentiction type which allows Moonshot to be used for
43  * authentication in web applications.  The module consists of two
44  * components: the hook function (gssweb_authenticate_user) that does
45  * most of the work, and an output filter (gssweb_authenticate_filter)
46  * that is registered by the hook function to send the output token
47  * back to the client in a json message that wraps the original
48  * response content.
49  *
50  * This module uses a simple protocol between the client and server
51  * to exchange GSS tokens and nonce information.  The protocol is 
52  * described in the protocol.txt file included with module source.
53  */
54
55 #include <stdio.h>
56 #include "mod_auth_gssweb.h"
57
58 module AP_MODULE_DECLARE_DATA auth_gssweb_module;
59
60 #define command(name, func, var, type, usage)           \
61   AP_INIT_ ## type (name, (void*) func,                 \
62         (void*)APR_OFFSETOF(gss_auth_config, var),      \
63         OR_AUTHCFG | RSRC_CONF, usage)
64
65 static const command_rec gssweb_config_cmds[] = {
66     command("GSSServiceName", ap_set_string_slot, service_name,
67             TAKE1, "Service name used for Apache authentication."),
68
69     { NULL }
70 };
71   
72 #define DEFAULT_ENCTYPE         "application/x-www-form-urlencoded"
73 #define GSS_MAX_TOKEN_SIZE      4096    //TBD -- check this value
74
75 /* gssweb_read_req() -- reads the request data into a buffer 
76  */
77 static int gssweb_read_req(request_rec *r, const char **rbuf, apr_off_t *size)
78 {
79   int rc = OK;
80
81   if((rc = ap_setup_client_block(r, REQUEST_CHUNKED_ERROR))) {
82     return(rc);
83   }
84   
85   if(ap_should_client_block(r)) {
86
87     char         argsbuffer[HUGE_STRING_LEN];
88     apr_off_t    rsize, len_read, rpos = 0;
89     apr_off_t length = r->remaining;
90
91     *rbuf = (const char *) apr_pcalloc(r->pool, (apr_size_t) (length + 1));
92     *size = length;
93     while((len_read = ap_get_client_block(r, argsbuffer, sizeof(argsbuffer))) > 0) {
94       if((rpos + len_read) > length) {
95         rsize = length - rpos;
96       }
97       else {
98         rsize = len_read;
99       }
100       
101       memcpy((char *) *rbuf + rpos, argsbuffer, (size_t) rsize);
102       rpos += rsize;
103     }
104   }
105   return(rc);
106 }
107
108 /* gssweb_get_post_data() -- Gets the token and nonce from the request
109  * data.
110  */
111 static int gssweb_get_post_data(request_rec *r, int *nonce, gss_buffer_desc *input_token)
112 {
113   const char *data;
114   apr_off_t datalen;
115   const char *key, *val, *type;
116   int rc = 0;
117
118   *nonce = 0;
119   input_token->length = 0;
120   input_token->value = NULL;
121
122   if(r->method_number != M_POST) {
123     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: Request data is not a POST, declining.");
124     return DECLINED;
125   }
126
127   type = apr_table_get(r->headers_in, "Content-Type");
128   if(strcasecmp(type, DEFAULT_ENCTYPE) != 0) {
129     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: Unexpected content type, declining.");
130     return DECLINED;
131   }
132
133   if((rc = gssweb_read_req(r, &data, &datalen)) != OK) {
134     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: Data read error, rc = %d", rc);
135     return rc;
136   }
137
138   while(*data && (val = ap_getword(r->pool, &data, '&'))) { 
139     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: obtained val from ap_getword() (%s)", val);
140     key = ap_getword(r->pool, &val, '=');
141     ap_unescape_url((char*)key);
142     ap_unescape_url((char*)val);
143     if (0 == strcasecmp(key, "token")) {
144       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: found token (%s)", val);
145       input_token->value = malloc(strlen(val));
146       input_token->length = apr_base64_decode(input_token->value, val);
147       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: Token successfully decoded.");
148     }
149     else if (0 == strcasecmp(key, "nonce")) {
150       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: found nonce (%s)", val);
151       *nonce = atoi(val);
152     }
153     else {
154       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: unknown key (%s)", key);
155     }
156   }
157   if ((0 == *nonce) || (0 == input_token->length)) {
158     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: nonce (%d) or token len (%d) is 0, declining", *nonce, input_token->length);
159     return DECLINED;
160   }
161   else {
162     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_get_post_data: returning nonce (%d) and token (%d bytes)", *nonce, input_token->length);
163     return OK;
164   }
165 }
166
167 /* gssweb_authenticate_filter() -- Output filter for gssweb authentication.
168  * Wraps original response in JSON -- adding JSON to the beginning of the 
169  * response, escapes double quotes in the original response, and adds JSON
170  * to the end of the response.  Handles responses that involve more than
171  * one filter call by maintaining state until an EOS bucket is received.
172  */
173 static apr_status_t gssweb_authenticate_filter (ap_filter_t *f,
174                                         apr_bucket_brigade *brig_in)
175 {
176   gss_log(APLOG_MARK, APLOG_DEBUG, 0, f->r, "Entering GSSWeb filter");
177
178   request_rec *r = f->r;
179   conn_rec *c = r->connection;
180   apr_bucket_brigade *brig_out;
181   apr_bucket *bkt_in = NULL;
182   apr_bucket *bkt_out = NULL;
183   apr_bucket *bkt_eos = NULL;
184   const char *data = NULL;
185   apr_size_t len = 0;
186   char *buf = NULL;
187   char *stoken = NULL;
188   apr_size_t n = 0, i = 0;
189   gss_conn_ctx conn_ctx = NULL;
190   const char *c_type = NULL;
191   const char *c_len = NULL;
192   apr_status_t ret = 0;
193
194   /* get the context from the request */
195   conn_ctx = gss_get_conn_ctx(r);
196   if ((NULL == conn_ctx) || 
197       (GSS_C_NO_CONTEXT == conn_ctx->context) ||
198       (GSS_CTX_EMPTY == conn_ctx->state) ||
199       (0 == conn_ctx->output_token.length)) {
200     conn_ctx->filter_stat = GSS_FILT_ERROR;
201     gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Failed to find valid context.");
202     apr_brigade_cleanup(brig_in);
203     return HTTP_INTERNAL_SERVER_ERROR;
204   }
205     
206   /* if this is the first call for a response, send opening JSON block */
207
208   if (GSS_FILT_NEW == conn_ctx->filter_stat) {
209     if (NULL == (brig_out = apr_brigade_create(r->pool, c->bucket_alloc))) {
210       conn_ctx->filter_stat = GSS_FILT_ERROR;
211       gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate output brigade (opening)");
212       apr_brigade_cleanup(brig_in);
213       return HTTP_INTERNAL_SERVER_ERROR;
214     }
215
216     len = apr_base64_encode_len(conn_ctx->output_token.length);
217     if (NULL == (data = apr_bucket_alloc(len+1024, c->bucket_alloc)) ||
218         NULL == (stoken = apr_bucket_alloc(len+1, c->bucket_alloc))) {
219       gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate space for opening json block");
220       apr_brigade_cleanup(brig_in);
221       apr_brigade_cleanup(brig_out);
222       return HTTP_INTERNAL_SERVER_ERROR;
223     }
224
225     apr_base64_encode_binary(stoken, conn_ctx->output_token.value, conn_ctx->output_token.length);
226     snprintf((char *)data, len+1024, 
227              "{\"gssweb\": {\n\"token\": \"%s\",\n\"nonce\": \"%d\"},\n\"application\": {\n\"data\": \"", 
228              stoken, conn_ctx->nonce);
229     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Sending: %s", data);
230     
231     bkt_out = apr_bucket_heap_create(data, strlen(data), apr_bucket_free,
232                                      c->bucket_alloc);
233     APR_BRIGADE_INSERT_TAIL(brig_out, bkt_out);
234     if (0 != (ret = ap_pass_brigade(f->next, brig_out))) {
235       apr_brigade_cleanup(brig_in);
236       apr_brigade_cleanup(brig_out);
237       return ret;
238     }
239
240     conn_ctx->filter_stat = GSS_FILT_INPROGRESS;
241   }
242
243   /* loop through the app data buckets, escaping and sending each one */
244   for (bkt_in = APR_BRIGADE_FIRST(brig_in);
245        bkt_in != APR_BRIGADE_SENTINEL(brig_in);
246        bkt_in = APR_BUCKET_NEXT(bkt_in))
247     {
248       if (NULL == (brig_out = apr_brigade_create(r->pool, c->bucket_alloc))) {
249             gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate brigade (loop)");
250             conn_ctx->filter_stat = GSS_FILT_ERROR;
251             apr_brigade_cleanup(brig_in);
252             return HTTP_INTERNAL_SERVER_ERROR;
253       }
254
255       /* if this is an EOS, send the JSON closing block */
256       if(APR_BUCKET_IS_EOS(bkt_in))
257         {
258           /* create and add the JSON closing block */
259           
260           if (NULL == (data = apr_bucket_alloc(1024, c->bucket_alloc))) {
261               gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate space for closing json block");
262               apr_brigade_cleanup(brig_in);
263               apr_brigade_cleanup(brig_out);
264               return HTTP_INTERNAL_SERVER_ERROR;
265           }
266
267           c_type = apr_table_get(r->headers_in, "Content-Type");
268           c_len = apr_table_get(r->headers_in, "Content-Length");
269           snprintf((char *)data, 1024, "\"\n\"content-type\": \"%s,\n\"content-length\": \"%s\"\n}\n}", c_type, c_len);
270           gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Sending: %s", data);
271
272           bkt_out = apr_bucket_heap_create(data, strlen(data), apr_bucket_free,
273                                            c->bucket_alloc);
274           APR_BRIGADE_INSERT_TAIL(brig_out, bkt_out);
275
276           /* Indicate that the next filter call is a new response */
277           conn_ctx->filter_stat = GSS_FILT_NEW;
278           
279           /* set EOS in the outbound brigade */
280           bkt_eos = apr_bucket_eos_create(c->bucket_alloc);
281           APR_BRIGADE_INSERT_TAIL (brig_out, bkt_eos);
282           
283           /* pass the brigade */
284           gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Sending: EOS");
285           if (0 != (ret = ap_pass_brigade(f->next, brig_out))) {
286             gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to pass output brigade (eos)");
287             conn_ctx->filter_stat = GSS_FILT_ERROR;
288             apr_brigade_cleanup(brig_in);
289             apr_brigade_cleanup(brig_out);
290             return ret;
291           }
292           break;
293         }
294
295       /* Read application data from each input bucket */
296       apr_bucket_read(bkt_in, &data, &len, APR_BLOCK_READ);
297       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Application Data (%d bytes): %s", len, data);
298
299       if (NULL == (buf = apr_bucket_alloc(len*2+1, c->bucket_alloc))) {
300         gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_filter: Unable to allocate space for application data");
301         apr_brigade_cleanup(brig_in);
302         apr_brigade_cleanup(brig_out);
303         return HTTP_INTERNAL_SERVER_ERROR;
304       }
305
306       /* Write data to an output brigade, escaping quotes */
307       for(n=0, i=0; n < len, i < 2*len ; n++) {
308         if ('"' != data[n]) {
309           buf[i++] = data[n];
310         } else {
311           /* Write the escaped quote character */
312           buf[i++] = '\\';
313           buf[i++] = '"';
314           /* Skip the quote character */
315         }
316       }
317       buf[i] = '\0';
318       bkt_out = apr_bucket_heap_create(buf, i, NULL, c->bucket_alloc);
319       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Sending: %s", buf);
320       APR_BRIGADE_INSERT_TAIL(brig_out, bkt_out);
321
322       /* Send the output brigade */
323       gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_filter: Passing the application data brigade");
324       if (OK != (ret = ap_pass_brigade(f->next, brig_out))) {
325         apr_brigade_cleanup(brig_in);
326         apr_brigade_cleanup(brig_out);
327         return ret;
328       }
329     }
330
331   /* Make sure we don't see the same data again */
332   apr_brigade_cleanup(brig_in);
333   return ret;
334 }
335
336 /* gssweb_add_filter() -- Hook to add our output filter to the request
337  * (r). Called for all error responses through the
338  * gssweb_insert_error_filter hook.
339  */
340 static void
341 gssweb_add_filter(request_rec *r) 
342 {
343   gss_conn_ctx conn_ctx = NULL;
344
345   /* Get the context for this request */
346   conn_ctx = gss_get_conn_ctx(r);
347   if (conn_ctx == NULL) {
348     gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_add_filter: Failed to find or create internal context.");
349     return;
350   }
351
352   /* Add the output filter */
353   ap_add_output_filter("gssweb_auth_filter", (void *)conn_ctx, r, r->connection);
354   return;
355 }
356
357 /* gssweb_authenticate_user() -- Hook to perform actual user
358  * authentication.  Will be called once for each round trip in the GSS
359  * authentication loop.  Reads the tokend from the request, calls
360  * gss_accept_sec_context(), and stores the output token and context
361  * in the user data areas.  Adds output filter to send the GSS
362  * output token back to the client.
363  */
364 static int
365 gssweb_authenticate_user(request_rec *r) 
366 {
367   gss_auth_config *conf = 
368     (gss_auth_config *) ap_get_module_config(r->per_dir_config,
369                                                 &auth_gssweb_module);
370   const char *auth_line = NULL;
371   char *auth_type = NULL;
372   char *negotiate_ret_value = NULL;
373   gss_conn_ctx conn_ctx = NULL;
374   int ret;
375   OM_uint32 major_status, minor_status, minor_status2;
376   gss_buffer_desc input_token = GSS_C_EMPTY_BUFFER;
377   gss_buffer_desc output_token = GSS_C_EMPTY_BUFFER;
378   gss_name_t client_name = GSS_C_NO_NAME;
379   gss_cred_id_t delegated_cred = GSS_C_NO_CREDENTIAL;
380   gss_cred_id_t server_creds = GSS_C_NO_CREDENTIAL;
381   OM_uint32 ret_flags = 0;
382   unsigned int nonce;
383
384   gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "Entering GSSWeb authentication");
385    
386   /* Check if this is for our auth type */
387   auth_type = (char *)ap_auth_type(r);
388   if (auth_type == NULL || strcasecmp(auth_type, "GSSWeb") != 0) {
389         gss_log(APLOG_MARK, APLOG_DEBUG, 0, r,
390                 "gssweb_authenticate_user: AuthType '%s' is not GSSWeb, bailing out",
391                 (auth_type) ? auth_type : "(NULL)");
392
393         return DECLINED;
394   }
395
396   /* Set up a GSS context for this request, if there isn't one already */
397   conn_ctx = gss_get_conn_ctx(r);
398   if (conn_ctx == NULL) {
399     gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_user: Failed to create internal context");
400     return HTTP_INTERNAL_SERVER_ERROR;
401   }
402
403   /* Read the token and nonce from the POST */
404   if (0 != gssweb_get_post_data(r, &nonce, &input_token)) {
405     ret = HTTP_UNAUTHORIZED;
406     gss_log(APLOG_MARK, APLOG_ERR, 0, r, "gssweb_authenticate_user: Unable to read nonce or input token.");
407     goto end;
408   }
409   gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_user: GSSWeb nonce value = %u.", nonce);
410    
411   /* If the nonce is set and doesn't match, start over */
412   if ((0 != conn_ctx->nonce) && (conn_ctx->nonce != nonce)) {
413     if (GSS_C_NO_CONTEXT != conn_ctx->context) {
414       gss_delete_sec_context(&minor_status, &conn_ctx->context, GSS_C_NO_BUFFER);
415     }
416     conn_ctx->context = GSS_C_NO_CONTEXT;
417     conn_ctx->state = GSS_CTX_EMPTY;
418     conn_ctx->filter_stat = GSS_FILT_NEW;
419     conn_ctx->user = NULL;
420     if (0 != conn_ctx->output_token.length) {
421       gss_release_buffer(&minor_status, &(conn_ctx->output_token));
422     }
423     conn_ctx->output_token.length = 0;
424   }
425  
426   /* If the output filter reported an internal server error, return it */
427   if (GSS_FILT_ERROR == conn_ctx->filter_stat) {
428     ret = HTTP_INTERNAL_SERVER_ERROR;
429     gss_log(APLOG_MARK, APLOG_ERR, 0, r,
430             "gssweb_authenticate_user: Output filter returned error, reporting.");
431     goto end;
432   }
433
434   /* Set-up the output filter (TBD -- register this once?) */
435   ap_register_output_filter("gssweb_auth_filter", gssweb_authenticate_filter, NULL, AP_FTYPE_RESOURCE);
436   ap_add_output_filter("gssweb_auth_filter", (void *)conn_ctx, r, r->connection);
437
438   /* Acquire server credentials (TBD -- do this once?) */
439   ret = get_gss_creds(r, conf, &server_creds);
440   if (ret)
441     goto end;
442   gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_user: Server credentials acquired.");
443     
444   /* Call gss_accept_sec_context */
445   major_status = gss_accept_sec_context(&minor_status,
446                                         &conn_ctx->context,
447                                         server_creds,
448                                         &input_token,
449                                         GSS_C_NO_CHANNEL_BINDINGS,
450                                         NULL,
451                                         NULL,
452                                         &output_token,
453                                         &ret_flags,
454                                         NULL,
455                                         &delegated_cred);
456   gss_log(APLOG_MARK, APLOG_DEBUG, 0, r,
457           "gssweb_authenticate_user: Client %s us their credential",
458           (ret_flags & GSS_C_DELEG_FLAG) ? "delegated" : "didn't delegate");
459
460   if (GSS_ERROR(major_status)) {
461     gss_log(APLOG_MARK, APLOG_ERR, 0, r,
462             "%s", get_gss_error(r, major_status, minor_status,
463                                 "gssweb_authenticate_user: Failed to establish authentication"));
464     gss_delete_sec_context(&minor_status, &conn_ctx->context, GSS_C_NO_BUFFER);
465     conn_ctx->context = GSS_C_NO_CONTEXT;
466     conn_ctx->state = GSS_CTX_EMPTY;
467     ret = HTTP_UNAUTHORIZED;
468     goto end;
469     gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_user: Decoding ouput token.");
470   }
471
472   gss_log(APLOG_MARK, APLOG_DEBUG, 0, r, "gssweb_authenticate_user: Got sec context, storing nonce and output token.");
473
474   /* Store the nonce & ouput token in the stored context */
475   conn_ctx->nonce = nonce;
476   conn_ctx->output_token = output_token;
477     
478   /* If we aren't done yet, go around again */
479   if (major_status & GSS_S_CONTINUE_NEEDED) {
480     conn_ctx->state = GSS_CTX_IN_PROGRESS;
481     ret = HTTP_UNAUTHORIZED;
482     goto end;
483   }
484
485   conn_ctx->state = GSS_CTX_ESTABLISHED;
486         r->user = apr_pstrdup(r->pool, conn_ctx->user);
487         r->ap_auth_type = "GSSWeb";
488   ret = OK;
489
490  end:
491   if (delegated_cred)
492     gss_release_cred(&minor_status, &delegated_cred);
493   
494   if (output_token.length) 
495     gss_release_buffer(&minor_status, &output_token);
496     
497   if (client_name != GSS_C_NO_NAME)
498     gss_release_name(&minor_status, &client_name);
499
500   if (server_creds != GSS_C_NO_CREDENTIAL)
501     gss_release_cred(&minor_status, &server_creds);
502
503   return ret;
504 }
505
506 static void
507 gssweb_register_hooks(apr_pool_t *p)
508 {
509     ap_hook_check_user_id(gssweb_authenticate_user, NULL, NULL, APR_HOOK_MIDDLE);
510     ap_hook_insert_error_filter(gssweb_add_filter, NULL, NULL, APR_HOOK_MIDDLE);
511 }
512
513 module AP_MODULE_DECLARE_DATA auth_gssweb_module = {
514     STANDARD20_MODULE_STUFF,
515     gss_config_dir_create,
516     NULL,
517     NULL,
518     NULL,
519     gssweb_config_cmds,
520     gssweb_register_hooks
521 };