Annotation of libwww/Library/src/HTAAUtil.html, revision 2.7
2.2 timbl 1: <HTML>
2.1 luotonen 2: <HEAD>
2.2 timbl 3: <TITLE>Utilities for the Authorization parts of libwww</TITLE></HEAD>
2.1 luotonen 4: <BODY>
2.2 timbl 5: <H1>Common Parts of Authorization Module
6: to Both Server And Browser</H1>This module is the interface to the
7: common parts of Access Authorization
8: (AA) package for both server and
9: browser. Important to know about
10: memory allocation:<P>
11: Routines in this module use dynamic
12: allocation, but free automatically
13: all the memory reserved by them.<P>
14: Therefore the caller never has to
15: (and never should) free() any object
16: returned by these functions.<P>
17: Therefore also all the strings returned
18: by this package are only valid until
19: the next call to the same function
20: is made. This approach is selected,
21: because of the nature of access authorization:
22: no string returned by the package
23: needs to be valid longer than until
24: the next call.<P>
25: This also makes it easy to plug the
26: AA package in: you don't have to
27: ponder whether to free() something
28: here or is it done somewhere else
29: (because it is always done somewhere
30: else).<P>
31: The strings that the package needs
32: to store are copied so the original
33: strings given as parameters to AA
34: functions may be freed or modified
35: with no side effects.<P>
36: Also note: The AA package does not
37: free() anything else than what it
38: has itself allocated.
2.1 luotonen 39: <PRE>
40: #ifndef HTAAUTIL_H
41: #define HTAAUTIL_H
42:
43: #include "HTUtils.h" /* BOOL, PARAMS, ARGS */
44: #include "HTList.h"
2.2 timbl 45: #include "tcp.h"
2.1 luotonen 46:
47: #ifdef SHORT_NAMES
48: #define HTAASenu HTAAScheme_enum
49: #define HTAASnam HTAAScheme_name
50: #define HTAAteMa HTAA_templateMatch
51: #define HTAAmaPT HTAA_makeProtectionTemplate
52: #define HTAApALi HTAA_parseArgList
53: #endif /*SHORT_NAMES*/
54:
55:
2.2 timbl 56: </PRE>
57: <H2>Default filenames</H2>
58: <PRE>#ifndef PASSWD_FILE
2.1 luotonen 59: #define PASSWD_FILE "/home2/luotonen/passwd"
60: #endif
61:
62: #ifndef GROUP_FILE
63: #define GROUP_FILE "/home2/luotonen/group"
64: #endif
65:
66: #define ACL_FILE_NAME ".www_acl"
67:
68:
69: /*
70: ** Numeric constants
71: */
72: #define MAX_USERNAME_LEN 16 /* @@ Longest allowed username */
2.5 luotonen 73: #define MAX_PASSWORD_LEN 4*13 /* @@ Longest allowed password */
74: /* (encrypted, so really only 4*8)*/
2.1 luotonen 75: #define MAX_METHODNAME_LEN 12 /* @@ Longest allowed method name */
76: #define MAX_FIELDNAME_LEN 16 /* @@ Longest field name in */
77: /* protection setup file */
78: #define MAX_PATHNAME_LEN 80 /* @@ Longest passwd/group file */
79: /* patname to allow */
80:
81: /*
82: ** Helpful macros
83: */
84: #define FREE(x) if (x) {free(x); x=NULL;}
85:
2.6 luotonen 86:
87: /*
88: ** Access Authorization failure reasons
89: */
90: typedef enum {
91: HTAA_OK, /* 200 OK */
92: HTAA_OK_GATEWAY, /* 200 OK, acting as a gateway */
2.7 ! luotonen 93: HTAA_OK_REDIRECT, /* 302 OK, redirected */
2.6 luotonen 94: HTAA_NO_AUTH, /* 401 Unauthorized, not authenticated */
95: HTAA_NOT_MEMBER, /* 401 Unauthorized, not authorized */
96: HTAA_IP_MASK, /* 403 Forbidden by IP mask */
97: HTAA_BY_RULE, /* 403 Forbidden by rule */
98: HTAA_NO_ACL, /* 403 Forbidden, ACL non-existent */
99: HTAA_NO_ENTRY, /* 403 Forbidden, no ACL entry */
100: HTAA_SETUP_ERROR, /* 403 Forbidden, server setup error */
101: HTAA_DOTDOT, /* 403 Forbidden, URL with /../ illegal */
102: HTAA_HTBIN, /* 403 Forbidden, /htbin not enabled */
2.7 ! luotonen 103: HTAA_INVALID_REDIRECT,
! 104: /* 403 Forbidden, bad redirection setup */
! 105: HTAA_NOT_ALLOWED, /* 403 Forbidden, dangerous method must */
! 106: /* be explicitly allowed */
2.6 luotonen 107: HTAA_NOT_FOUND /* 404 Not found, or read protected */
108: } HTAAFailReason;
109:
110:
2.1 luotonen 111: </PRE>
112: <H2>Datatype definitions</H2>
2.2 timbl 113: <H3>HTAAScheme</H3>The enumeration HTAAScheme represents
114: the possible authentication schemes
115: used by the WWW Access Authorization.
2.1 luotonen 116: <PRE>
117: typedef enum {
118: HTAA_UNKNOWN,
119: HTAA_NONE,
120: HTAA_BASIC,
121: HTAA_PUBKEY,
122: HTAA_KERBEROS_V4,
123: HTAA_KERBEROS_V5,
124: HTAA_MAX_SCHEMES /* THIS MUST ALWAYS BE LAST! Number of schemes */
125: } HTAAScheme;
126:
2.2 timbl 127: </PRE>
2.1 luotonen 128:
129: <H2>Authentication Schemes</H2>
130: <PRE>
131: /* PUBLIC HTAAScheme_enum()
132: ** TRANSLATE SCHEME NAME TO A SCHEME ENUMERATION
133: ** ON ENTRY:
134: ** name is a string representing the scheme name.
135: **
136: ** ON EXIT:
137: ** returns the enumerated constant for that scheme.
138: */
139: PUBLIC HTAAScheme HTAAScheme_enum PARAMS((CONST char* name));
140:
141:
142: /* PUBLIC HTAAScheme_name()
143: ** GET THE NAME OF A GIVEN SCHEME
144: ** ON ENTRY:
145: ** scheme is one of the scheme enum values:
146: ** HTAA_NONE, HTAA_BASIC, HTAA_PUBKEY, ...
147: **
148: ** ON EXIT:
149: ** returns the name of the scheme, i.e.
150: ** "none", "basic", "pubkey", ...
151: */
152: PUBLIC char *HTAAScheme_name PARAMS((HTAAScheme scheme));
2.2 timbl 153:
2.1 luotonen 154:
2.7 ! luotonen 155: /* PUBLIC HTAA_templateCaseMatch()
2.4 duns 156: ** STRING COMPARISON FUNCTION FOR FILE NAMES
157: ** WITH ONE WILDCARD * IN THE TEMPLATE (Case Insensitive)
158: ** NOTE:
159: ** This is essentially the same code as in HTAA_templateMatch, but
160: ** it compares case insensitive (for VMS). Reason for this routine
161: ** is that HTAA_templateMatch gets called from several places, also
162: ** there where a case sensitive match is needed, so one cannot just
163: ** change the HTAA_templateMatch routine for VMS.
164: **
165: ** ON ENTRY:
166: ** template is a template string to match the file name
167: ** agaist, may contain a single wildcard
168: ** character * which matches zero or more
169: ** arbitrary characters.
170: ** filename is the filename (or pathname) to be matched
171: ** agaist the template.
172: **
173: ** ON EXIT:
174: ** returns YES, if filename matches the template.
175: ** NO, otherwise.
176: */
177: PUBLIC BOOL HTAA_templateCaseMatch PARAMS((CONST char * template,
2.7 ! luotonen 178: CONST char * filename));
2.4 duns 179:
180:
2.1 luotonen 181: /* PUBLIC HTAA_makeProtectionTemplate()
182: ** CREATE A PROTECTION TEMPLATE FOR THE FILES
183: ** IN THE SAME DIRECTORY AS THE GIVEN FILE
184: ** (Used by server if there is no fancier way for
185: ** it to tell the client, and by browser if server
186: ** didn't send WWW-ProtectionTemplate: field)
187: ** ON ENTRY:
188: ** docname is the document pathname (from URL).
189: **
190: ** ON EXIT:
191: ** returns a template matching docname, and other files
192: ** files in that directory.
193: **
194: ** E.g. /foo/bar/x.html => /foo/bar/ *
195: ** ^
196: ** Space only to prevent it from
197: ** being a comment marker here,
198: ** there really isn't any space.
199: */
200: PUBLIC char *HTAA_makeProtectionTemplate PARAMS((CONST char * docname));
201: </PRE>
202: <H2>MIME Argument List Parser</H2>
203: <PRE>
204:
205: /* PUBLIC HTAA_parseArgList()
206: ** PARSE AN ARGUMENT LIST GIVEN IN A HEADER FIELD
207: ** ON ENTRY:
208: ** str is a comma-separated list:
209: **
210: ** item, item, item
211: ** where
212: ** item ::= value
213: ** | name=value
214: ** | name="value"
215: **
216: ** Leading and trailing whitespace is ignored
217: ** everywhere except inside quotes, so the following
218: ** examples are equal:
219: **
220: ** name=value,foo=bar
221: ** name="value",foo="bar"
222: ** name = value , foo = bar
223: ** name = "value" , foo = "bar"
224: **
225: ** ON EXIT:
226: ** returns a list of name-value pairs (actually HTAssocList*).
227: ** For items with no name, just value, the name is
228: ** the number of order number of that item. E.g.
229: ** "1" for the first, etc.
230: */
231: PUBLIC HTList *HTAA_parseArgList PARAMS((char * str));
232:
233: </PRE>
2.5 luotonen 234:
2.1 luotonen 235: <PRE>
236: #endif /* NOT HTAAUTIL_H */
2.2 timbl 237: </PRE>End of file HTAAUtil.h.</BODY>
238: </HTML>
Webmaster