home *** CD-ROM | disk | FTP | other *** search
/ Collection of Internet / Collection of Internet.iso / msdos / lynx / source / www / library / implemen / htaabrow.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-25  |  5.4 KB  |  136 lines

  1. /*                          BROWSER SIDE ACCESS AUTHORIZATION MODULE
  2.                                              
  3.    This module is the browser side interface to Access Authorization (AA) package.  It
  4.    contains code only for browser.
  5.    
  6.    Important to know about memory allocation:
  7.    
  8.    Routines in this module use dynamic allocation, but free automatically all the memory
  9.    reserved by them.
  10.    
  11.    Therefore the caller never has to (and never should) free() any object returned by
  12.    these functions.
  13.    
  14.    Therefore also all the strings returned by this package are only valid until the next
  15.    call to the same function is made. This approach is selected, because of the nature of
  16.    access authorization: no string returned by the package needs to be valid longer than
  17.    until the next call.
  18.    
  19.    This also makes it easy to plug the AA package in: you don't have to ponder whether to
  20.    free()something here or is it done somewhere else (because it is always done somewhere
  21.    else).
  22.    
  23.    The strings that the package needs to store are copied so the original strings given as
  24.    parameters to AA functions may be freed or modified with no side effects.
  25.    
  26.    Also note:The AA package does not free() anything else than what it has itself
  27.    allocated.
  28.    
  29.  */
  30.  
  31. #ifndef HTAABROW_H
  32. #define HTAABROW_H
  33.  
  34. #include "HTUtils.h"            /* BOOL, PARAMS, ARGS */
  35. #include "HTAAUtil.h"           /* Common parts of AA */
  36.  
  37.  
  38. #ifdef SHORT_NAMES
  39. #define HTAAcoAu        HTAA_composeAuth
  40. #define HTAAsRWA        HTAA_shouldRetryWithAuth
  41. #endif /*SHORT_NAMES*/
  42.  
  43. /*
  44.  
  45. Routines for Browser Side Recording of AA Info
  46.  
  47.    Most of the browser-side AA is done by the following two functions (which are called
  48.    from file HTTP.c so the browsers using libwww only need to be linked with the new
  49.    library and not be changed at all):
  50.    
  51.       HTAA_composeAuth() composes the Authorization: line contents, if the AA package
  52.       thinks that the given document is protected. Otherwise this function returns NULL.
  53.       This function also calls the functions HTPrompt(),HTPromptPassword() and HTConfirm()
  54.       to get the username, password and some confirmation from the user.
  55.       
  56.       HTAA_shouldRetryWithAuth() determines whether to retry the request with AA or with a
  57.       new AA (in case username or password was misspelled).
  58.       
  59.  */
  60.  
  61. /* PUBLIC                                               HTAA_composeAuth()
  62. **
  63. **      COMPOSE THE ENTIRE AUTHORIZATION HEADER LINE IF WE
  64. **      ALREADY KNOW, THAT THE HOST MIGHT REQUIRE AUTHORIZATION
  65. **
  66. ** ON ENTRY:
  67. **      hostname        is the hostname of the server.
  68. **      portnumber      is the portnumber in which the server runs.
  69. **      docname         is the pathname of the document (as in URL)
  70. **
  71. ** ON EXIT:
  72. **      returns NULL, if no authorization seems to be needed, or
  73. **              if it is the entire Authorization: line, e.g.
  74. **
  75. **                 "Authorization: basic username:password"
  76. **
  77. **              As usual, this string is automatically freed.
  78. */
  79. PUBLIC char *HTAA_composeAuth PARAMS((CONST char * hostname,
  80.                                       CONST int   portnumber,
  81.                                       CONST char * docname));
  82.  
  83.  
  84. /* BROWSER PUBLIC                               HTAA_shouldRetryWithAuth()
  85. **
  86. **              DETERMINES IF WE SHOULD RETRY THE SERVER
  87. **              WITH AUTHORIZATION
  88. **              (OR IF ALREADY RETRIED, WITH A DIFFERENT
  89. **              USERNAME AND/OR PASSWORD (IF MISSPELLED))
  90. ** ON ENTRY:
  91. **      start_of_headers is the first block already read from socket,
  92. **                      but status line skipped; i.e. points to the
  93. **                      start of the header section.
  94. **      length          is the remaining length of the first block.
  95. **      soc             is the socket to read the rest of server reply.
  96. **
  97. **                      This function should only be called when
  98. **                      server has replied with a 401 (Unauthorized)
  99. **                      status code.
  100. ** ON EXIT:
  101. **      returns         YES, if connection should be retried.
  102. **                           The node containing all the necessary
  103. **                           information is
  104. **                              * either constructed if it does not exist
  105. **                              * or password is reset to NULL to indicate
  106. **                                that username and password should be
  107. **                                reprompted when composing Authorization:
  108. **                                field (in function HTAA_composeAuth()).
  109. **                      NO, otherwise.
  110. */
  111. PUBLIC BOOL HTAA_shouldRetryWithAuth PARAMS((char *     start_of_headers,
  112.                                              int        length,
  113.                                              int        soc));
  114. /*
  115.  
  116. Enabling Gateway httpds to Forward Authorization
  117.  
  118.    These functions should only be called from daemon code, and HTAAForwardAuth_reset()
  119.    must be called before the next request is handled to make sure that authorization
  120.    string isn't cached in daemon so that other people can access private files using
  121.    somebody elses previous authorization information.
  122.    
  123.  */
  124.  
  125. PUBLIC void HTAAForwardAuth_set PARAMS((CONST char * scheme_name,
  126.                                         CONST char * scheme_specifics));
  127. PUBLIC void HTAAForwardAuth_reset NOPARAMS;
  128. /*
  129.  
  130.  */
  131.  
  132. #endif  /* NOT HTAABROW_H */
  133. /*
  134.  
  135.    End of file HTAABrow.h.  */
  136.