about summary refs log tree commit diff stats
path: root/WWW/Library/Implementation/HTAAServ.h
blob: dc03c7dd1ae3e4dea09c8de2397c571e53ef629e (plain) (blame)
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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*                          SERVER SIDE ACCESS AUTHORIZATION MODULE
                                             
   This module is the server side interface to Access Authorization (AA) package. It
   contains code only for server.
   
   Important to know about memory allocation:
   
   Routines in this module use dynamic allocation, but free automatically all the memory
   reserved by them.
   
   Therefore the caller never has to (and never should) free() any object returned by
   these functions.
   
   Therefore also all the strings returned by this package are only valid until the next
   call to the same function is made. This approach is selected, because of the nature of
   access authorization: no string returned by the package needs to be valid longer than
   until the next call.
   
   This also makes it easy to plug the AA package in: you don't have to ponder whether to
   free()something here or is it done somewhere else (because it is always done somewhere
   else).
   
   The strings that the package needs to store are copied so the original strings given as
   parameters to AA functions may be freed or modified with no side effects.
   
   Also note:The AA package does not free() anything else than what it has itself
   allocated.
   
 */

#ifndef HTAASERV_H
#define HTAASERV_H

#ifndef HTUTILS_H
#include "HTUtils.h"            /* BOOL, PARAMS, ARGS   */
#endif /* HTUTILS_H */
/*#include <stdio.h> included by HTUtils.h -- FM *//* FILE                */
#include "HTRules.h"            /* This module interacts with rule system */
#include "HTAAUtil.h"           /* Common parts of AA   */
#include "HTAuth.h"             /* Authentication       */


#ifdef SHORT_NAMES
#define HTAAstMs        HTAA_statusMessage
#define HTAAchAu        HTAA_checkAuthorization
#define HTAAcoAH        HTAA_composeAuthHeaders
#define HTAAsLog        HTAA_startLogging
#endif /*SHORT_NAMES*/

extern time_t theTime;

/*

Check Access Authorization

   HTAA_checkAuthorization() is the main access authorization function.
   
 */

/* PUBLIC                                             HTAA_checkAuthorization()
**              CHECK IF USER IS AUTHORIZED TO ACCESS A FILE
** ON ENTRY:
**      url             is the document to be accessed.
**      method_name     name of the method, e.g. "GET"
**      scheme_name     authentication scheme name.
**      scheme_specifics authentication string (or other
**                      scheme specific parameters, like
**                      Kerberos-ticket).
**
** ON EXIT:
**      returns status codes uniform with those of HTTP:
**        200 OK           if file access is ok.
**        401 Unauthorized if user is not authorized to
**                         access the file.
**        403 Forbidden    if there is no entry for the
**                         requested file in the ACL.
**
** NOTE:
**      This function does not check whether the file
**      exists or not -- so the status  404 Not found
**      must be returned from somewhere else (this is
**      to avoid unnecessary overhead of opening the
**      file twice).
**
*/
PUBLIC int HTAA_checkAuthorization PARAMS((CONST char * url,
                                           CONST char * method_name,
                                           CONST char * scheme_name,
                                           char *       scheme_specifics));
/*

Compose Status Line Message

 */

/* SERVER PUBLIC                                        HTAA_statusMessage()
**              RETURN A STRING EXPLAINING ACCESS
**              AUTHORIZATION FAILURE
**              (Can be used in server reply status line
**               with 401/403 replies.)
** ON EXIT:
**      returns a string containing the error message
**              corresponding to internal HTAAFailReason.
*/
PUBLIC char *HTAA_statusMessage NOPARAMS;
/*

Compose "Authenticate:" Header Lines for Server Reply

 */

/* SERVER PUBLIC                                    HTAA_composeAuthHeaders()
**              COMPOSE WWW-Authenticate: HEADER LINES
**              INDICATING VALID AUTHENTICATION SCHEMES
**              FOR THE REQUESTED DOCUMENT
** ON ENTRY:
**      No parameters, but HTAA_checkAuthorization() must
**      just before have failed because a wrong (or none)
**      authentication scheme was used.
**
** ON EXIT:
**      returns a buffer containing all the WWW-Authenticate:
**              fields including CRLFs (this buffer is auto-freed).
**              NULL, if authentication won't help in accessing
**              the requested document.
*/
PUBLIC char *HTAA_composeAuthHeaders NOPARAMS;
/*

Start Access Authorization Logging

 */

/* PUBLIC                                               HTAA_startLogging()
**              START UP ACCESS AUTHORIZATION LOGGING
** ON ENTRY:
**      fp      is the open log file.
**
*/
PUBLIC void HTAA_startLogging PARAMS((FILE * fp));
/*

 */

#endif  /* NOT HTAASERV_H */
/*

   End of file HTAAServ.h.  */