Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

283 lines
8.2 KiB

  1. /*++
  2. Copyright (c) 1996 Microsoft Corporation
  3. Module Name:
  4. spluginx.hxx
  5. Abstract:
  6. This file contains headers for the WININET
  7. HTTP Authentication Plug In Model.
  8. Contents:
  9. AuthenticateUser
  10. PreAuthenticateUser
  11. UnloadAuthenticateUser
  12. AuthenticateUserUI
  13. Author:
  14. Arthur Bierer (arthurbi) 04-Apr-1996
  15. Revision History:
  16. 04-Apr-1996 arthurbi
  17. Created
  18. --*/
  19. //
  20. // Macros and Defines for Authentication UI
  21. //
  22. #define MAX_FIELD_LENGTH MAX_PATH
  23. typedef enum tagAuthType
  24. {
  25. REALM_AUTH = 0,
  26. NTLM_AUTH = 1,
  27. PASSPORT_AUTH = 2
  28. } AuthType;
  29. typedef struct tagInvalidPassType
  30. {
  31. LPSTR lpszRealm;
  32. LPSTR lpszUsername;
  33. LPSTR lpszPassword;
  34. LPSTR lpszHost;
  35. ULONG ulMaxField;
  36. BOOL fIsProxy;
  37. AuthType eAuthType;
  38. } InvalidPassType;
  39. #ifdef __cplusplus
  40. extern "C" {
  41. #endif
  42. //
  43. // AuthenticateUser - Called on recept of a 401 or 407 status code
  44. // from the Web Server. This function should attempt to
  45. // validate the Server's 401/407 response, and generate
  46. // ERROR_SUCCESS if it accepts this Server for authentication
  47. // Otherwise this function should returns an appropriate
  48. // error found in wininet.h, or winerror.h
  49. //
  50. // lppvContext - pointer to Context pointer that will be passed on
  51. // every unquie conversation with the Server. Will be a pointer to a
  52. // NULL the first time this function is called for a unquie session.
  53. // Its the Function's responsiblity to allocate or generate a unquie context
  54. // value that will be passed on future calls.
  55. //
  56. // lpszServerName - Host Name of Web server.
  57. // lpszScheme - Name of Authentication Scheme being used, ie Basic, MSN, NTLM..
  58. // dwFlags - Flags.
  59. // lpszUserName - Possible UserName if availble.
  60. // lpszPassword - Possible Password if availble.
  61. //
  62. // RETURNS:
  63. // ERROR_SUCCESS - Means it accepts this connection as valid, and
  64. // asks for the authentication to continue by restarting
  65. // the HTTP connection, and calling PreAuthenticateUser BEFORE
  66. // that new HTTP connection is opened.
  67. //
  68. // ERROR_INTERNET_INCORRECT_PASSWORD - Means we do not understand this
  69. // username and/or password that is passed to us. Will
  70. // return to User or Application for new username and password.
  71. //
  72. // ERROR_INTERNET_FORCE_RETRY - An additional 401/407 response may
  73. // need to be generated from the server. Forces PreAuthenticateUser
  74. // to be recalled, and new HTTP connection/request. The difference
  75. // is WININET will expect a 401/407 to be generated from this request.
  76. //
  77. #if defined(unix) && defined(__cplusplus)
  78. extern "C"
  79. #endif
  80. DWORD
  81. WINAPI
  82. AuthenticateUser(
  83. IN OUT LPVOID* lppvContext,
  84. IN LPSTR lpszServerName,
  85. IN LPSTR lpszScheme,
  86. IN BOOL fCanUseLogon,
  87. IN LPSTR lpszParsedAuthHeader,
  88. IN DWORD dwcbParsedAuthHeader,
  89. IN LPSTR lpszUserName,
  90. IN LPSTR lpszPassword,
  91. IN PCSTR lpszUrl,
  92. OUT SECURITY_STATUS *pssResult
  93. );
  94. //
  95. // PreAuthenticateUser - Called on BEFORE doing a GET or POST
  96. // to a Web Server. This function is called only if there
  97. // has been a previous connection with the server using the
  98. // passed in Scheme.
  99. //
  100. // This function will attempt to Generate a proper set of
  101. // encoded bytes that can be sent to the server on a HTTP
  102. // header. If lpdwOutBufferLength is not large enough
  103. // ERROR_INSUFFICENT_BUFFER can be returned with the correct
  104. // size stored in lpdwOutBufferLength.
  105. //
  106. // lppvContext - pointer to Context pointer that will be passed on
  107. // every unquie conversation with the Server.
  108. // lpszServerName - Host Name of Web server.
  109. // lpszScheme - Name of Authentication Scheme being used, ie Basic, MSN, NTLM..
  110. // fCanUseLogon - whether zone policy allows ntlm to use logon credential
  111. // lpOutBuffer - Pointer to Buffer that will contain output encoded header bytes.
  112. // lpdwOutBufferLength - Size of Buffer Above, will contain size of buffer above,
  113. // on return will contain bytes actually stored.
  114. // lpszUserName - Possible UserName if availble.
  115. // lpszPassword - Possible Password if availble.
  116. //
  117. //
  118. #if defined(unix) && defined(__cplusplus)
  119. extern "C"
  120. #endif
  121. DWORD
  122. WINAPI
  123. PreAuthenticateUser(
  124. IN OUT LPVOID* lppvContext,
  125. IN LPSTR lpszServerName,
  126. IN LPSTR lpszScheme,
  127. IN DWORD dwFlags,
  128. OUT LPSTR lpOutBuffer,
  129. IN OUT LPDWORD lpdwOutBufferLength,
  130. IN LPSTR lpszUserName,
  131. IN LPSTR lpszPassword,
  132. IN PCSTR lpszUrl,
  133. OUT SECURITY_STATUS *pssResult
  134. );
  135. //
  136. // UnloadAuthenticateUser - Called after HTTP authentication
  137. // has been completed, and the authentication process is
  138. // no longer needed.
  139. //
  140. // Its intended for cleanup of context memory that was allocated.
  141. // NOTE: For certain schemes these context values may live
  142. // until shutdown.
  143. //
  144. #if defined(unix) && defined(__cplusplus)
  145. extern "C"
  146. #endif
  147. VOID
  148. WINAPI
  149. UnloadAuthenticateUser(
  150. IN OUT LPVOID* lppvContext,
  151. IN LPSTR lpszScheme,
  152. IN LPSTR lpszHost
  153. );
  154. //
  155. // AuthenticateUserUI - This function is called when a application
  156. // called InternetErrorDlg for the purposes of generating UI on
  157. // a specific HTTP Authentication Scheme. For example, if a User
  158. // required a login to the MSN service. An application could
  159. // call InternetErrorDlg to generate UI, and WinINet would
  160. // determine that MSN could handle the UI for quering the user/passwd
  161. // internaly.
  162. //
  163. // Note: An application does not need to generate the UserName,
  164. // and Password for WININET in pAuthInfo. Rather it could simply
  165. // return an ERROR_SUCCESS, and have its PreAuthenticeUser recalled.
  166. //
  167. // Note: To Cancel the authentication process. ERROR_CANCELLED should
  168. // be returned.
  169. //
  170. // lppvContext - pointer to Authenticateion Context.
  171. // hWnd - Windows Handle to Parent Window
  172. // dwError - Error code passed to InternetErrorDlg
  173. // dwFlags - flags.
  174. // pAuthInfo - Pointer to structure containing a place to store
  175. // Username and password
  176. #if defined(unix) && defined(__cplusplus)
  177. extern "C"
  178. #endif
  179. DWORD
  180. WINAPI
  181. AuthenticateUserUI(
  182. IN OUT LPVOID* lppvContext,
  183. IN HWND hWnd,
  184. IN DWORD dwError,
  185. IN DWORD dwFlags,
  186. IN OUT InvalidPassType* pAuthInfo,
  187. IN LPSTR lpszScheme,
  188. IN PCSTR lpszUrl,
  189. SECURITY_STATUS *pssResult
  190. );
  191. #ifdef __cplusplus
  192. } // end extern "C"
  193. #endif
  194. //
  195. // Registry Flags Used for Defining what kind of authentication a
  196. // plugin may support.
  197. //
  198. //
  199. // Each TCP/IP Socket will contain a different Context.
  200. // Otherwise a new context will be passed for each Realm
  201. // or block URL template (http://www.foo.com/directory/*).
  202. //
  203. #define PLUGIN_AUTH_FLAGS_UNIQUE_CONTEXT_PER_TCPIP 0x01
  204. //
  205. // This PlugIn Can handle doing it's own UI. So call it
  206. // when UI is needed.
  207. //
  208. #define PLUGIN_AUTH_FLAGS_CAN_HANDLE_UI 0x02
  209. //
  210. // This PlugIn may be capible of doing an Authentication
  211. // without prompting the User for a Password. If this
  212. // is not the case AuthenticateUser should return
  213. // ERROR_INTERNET_INCORRECT_PASSWORD
  214. //
  215. #define PLUGIN_AUTH_FLAGS_CAN_HANDLE_NO_PASSWD 0x04
  216. //
  217. // This PlugIn does not use a standard HTTP Realm
  218. // string. Any data that appears to be a realm
  219. // is scheme specific data.
  220. //
  221. #define PLUGIN_AUTH_FLAGS_NO_REALM 0x08
  222. //
  223. // This PlugIn doesn't need a persistent connection for challenge-response.
  224. //
  225. #define PLUGIN_AUTH_FLAGS_KEEP_ALIVE_NOT_REQUIRED 0x10
  226. //
  227. // Registry Values
  228. // To Register a Security PlugIn called FOO, place a key in
  229. // HKLM\Software\Microsoft\Internet Explorer\Security\FOO
  230. // In Foo Create the following values:
  231. // Flags 0x00000000 ( see above for Registry Flags )
  232. //