paulb@391 | 1 | Webware's CGI Adapter
|
paulb@391 | 2 | =====================
|
paulb@35 | 3 |
|
paulb@35 | 4 | Copy the Webware/WebKit/Adapters/WebKit.cgi file to your CGI directory (eg.
|
paulb@391 | 5 | /home/httpd/cgi-bin) and ensure that the permissions are appropriate for a CGI
|
paulb@391 | 6 | program.
|
paulb@391 | 7 |
|
paulb@391 | 8 | Configuring in Apache
|
paulb@391 | 9 | ---------------------
|
paulb@391 | 10 |
|
paulb@391 | 11 | Add a line like this to your Apache configuration file (eg. httpd.conf):
|
paulb@35 | 12 |
|
paulb@35 | 13 | ScriptAlias /webkit "/home/httpd/cgi-bin/WebKit.cgi"
|
paulb@35 | 14 |
|
paulb@391 | 15 | Configuring in AOLserver
|
paulb@391 | 16 | ------------------------
|
paulb@391 | 17 |
|
paulb@444 | 18 | NOTE: AOLserver does not seem to handle "URL encoded" character values
|
paulb@444 | 19 | NOTE: properly when such values appear in the path before the query string.
|
paulb@444 | 20 |
|
paulb@391 | 21 | Ensure the presence of the following lines in your configuration file (eg.
|
paulb@391 | 22 | config.tcl):
|
paulb@35 | 23 |
|
paulb@391 | 24 | ns_section "ns/server/${servername}/module/nscgi"
|
paulb@391 | 25 | ns_param map "GET /webkit /home/httpd/cgi-bin/WebKit.cgi" ;# CGI script file dir (GET).
|
paulb@391 | 26 | ns_param map "POST /webkit /home/httpd/cgi-bin/WebKit.cgi" ;# CGI script file dir (POST).
|
paulb@391 | 27 | ns_param interps CGIinterps
|
paulb@391 | 28 |
|
paulb@391 | 29 | ns_section "ns/interps/CGIinterps"
|
paulb@391 | 30 | ns_param .cgi "/usr/bin/python"
|
paulb@391 | 31 |
|
paulb@391 | 32 | See docs/CGI/NOTES.txt for more information on AOLserver and CGI
|
paulb@391 | 33 | configuration.
|
paulb@391 | 34 |
|
paulb@444 | 35 | Patches for CGIAdapter when working with AOLserver
|
paulb@444 | 36 | --------------------------------------------------
|
paulb@444 | 37 |
|
paulb@444 | 38 | AOLserver appears to set empty CONTENT_LENGTH environment variable values. A
|
paulb@444 | 39 | patch for CGIAdapter.py in WebKit can be applied as follows (with a suitable
|
paulb@444 | 40 | relative path to WebStack from Webware/WebKit):
|
paulb@444 | 41 |
|
paulb@444 | 42 | cd Webware/WebKit
|
paulb@444 | 43 | patch -p0 < ../../WebStack/patches/Webware/WebKit/CGIAdapter.py.diff
|
paulb@444 | 44 |
|
paulb@391 | 45 | Authentication/Authorisation in Webware
|
paulb@391 | 46 | =======================================
|
paulb@52 | 47 |
|
paulb@52 | 48 | Since Webware provides some kind of CGI emulation environment, the actual HTTP
|
paulb@52 | 49 | headers involved with authentication/authorisation are not available to the
|
paulb@52 | 50 | WebStack transaction. Therefore, WebStack depends on Webware having access to
|
paulb@52 | 51 | the REMOTE_USER environment variable set by the Web server, and with Apache,
|
paulb@52 | 52 | this variable is only ever set when Apache itself has performed
|
paulb@52 | 53 | authentication. Whilst applications can send the "WWW-Authenticate" header to
|
paulb@52 | 54 | HTTP clients, unless Apache has been instructed to process the resulting
|
paulb@52 | 55 | username/password information, the REMOTE_USER will apparently remain
|
paulb@52 | 56 | undefined.
|
paulb@52 | 57 |
|
paulb@52 | 58 | Consequently, it is recommended that the following kind of definition is added
|
paulb@52 | 59 | to httpd.conf (for Apache) in order to give applications access to
|
paulb@52 | 60 | username/password details:
|
paulb@52 | 61 |
|
paulb@52 | 62 | <Location "/webkit/auth">
|
paulb@52 | 63 | AuthType Basic
|
paulb@52 | 64 | AuthName "AuthResource"
|
paulb@52 | 65 | AuthUserFile /usr/local/apache2/conf/users
|
paulb@52 | 66 | require valid-user
|
paulb@52 | 67 | </Location>
|
paulb@52 | 68 |
|
paulb@52 | 69 | The details of the application's deployment, including the exact pathname of
|
paulb@52 | 70 | the users file and the appropriate access policy, must obviously be defined
|
paulb@52 | 71 | according to the actual application concerned.
|
paulb@52 | 72 |
|
paulb@58 | 73 | Note that the above example will only apply authentication to either a
|
paulb@58 | 74 | specific context (for Webware releases beyond 0.8.1) and only to a specific
|
paulb@58 | 75 | "region" of possible URLs (for Webware 0.8.1 and earlier).
|
paulb@58 | 76 |
|
paulb@391 | 77 | For Webware Releases Beyond 0.8.1
|
paulb@391 | 78 | =================================
|
paulb@35 | 79 |
|
paulb@35 | 80 | WebStack applications are supported as contexts within WebKit, meaning that a
|
paulb@35 | 81 | certain prefix in the URL determines whether an application is sent a
|
paulb@35 | 82 | particular request.
|
paulb@35 | 83 |
|
paulb@35 | 84 | Each context must be defined in the Webware/WebKit/Configs/Application.config
|
paulb@437 | 85 | file within the 'Contexts' dictionary; for example:
|
paulb@35 | 86 |
|
paulb@437 | 87 | Contexts['simple'] = '/home/paulb/Software/Python/WebStack/examples/Webware/SimpleContext'
|
paulb@35 | 88 |
|
paulb@35 | 89 | Note that the path to the context directory must be absolute, although the
|
paulb@35 | 90 | context directory may reside within WebKit itself such that the path may then
|
paulb@437 | 91 | make use of the special WebKitPath variable.
|
paulb@35 | 92 |
|
paulb@44 | 93 | Note also that the name of the context (eg. 'simple') must not be the same as
|
paulb@44 | 94 | the name of any other package used within the application (and possibly any
|
paulb@44 | 95 | other applications in the application server), with the only reasonable
|
paulb@44 | 96 | exception being the context package name itself (eg. 'SimpleContext').
|
paulb@44 | 97 | Otherwise, the existing package will become overridden by the contents of the
|
paulb@44 | 98 | context itself. Therefore, given that the Simple package is used to hold the
|
paulb@44 | 99 | actual application code, it is not wise to use 'Simple' as the context name.
|
paulb@44 | 100 |
|
paulb@35 | 101 | Running the application server:
|
paulb@35 | 102 |
|
paulb@35 | 103 | Change into the WebKit directory within Webware. Then, specifying the
|
paulb@35 | 104 | appropriate PYTHONPATH, invoke the application server. For example:
|
paulb@35 | 105 |
|
paulb@437 | 106 | PYTHONPATH=../../WebStack:../../WebStack/examples/Common ./AppServer
|
paulb@35 | 107 |
|
paulb@35 | 108 | The WebStack package must reside on the PYTHONPATH, along with the package
|
paulb@35 | 109 | containing the application itself.
|
paulb@35 | 110 |
|
paulb@391 | 111 | For Webware 0.8.1 or Earlier
|
paulb@391 | 112 | ============================
|
paulb@35 | 113 |
|
paulb@35 | 114 | Support for WebStack applications is provided by a Webware plug-in which
|
paulb@35 | 115 | associates Webware resources having certain suffixes with certain WebStack
|
paulb@35 | 116 | applications, regardless of the context within which a resource appears. In
|
paulb@35 | 117 | order to make use of such a scheme, a WebStack application would have its
|
paulb@35 | 118 | resources residing in an arbitrary URL "hierarchy", but with each resource
|
paulb@35 | 119 | having the special suffix to indicate that it belongs to that application.
|
paulb@35 | 120 |
|
paulb@35 | 121 | In the case of an application whose chosen suffix is ".xyz", it would be
|
paulb@35 | 122 | possible, for example, to define resources residing at the following URL
|
paulb@35 | 123 | paths:
|
paulb@35 | 124 |
|
paulb@35 | 125 | tasks/my-tasks.xyz
|
paulb@35 | 126 | tasks/outstanding/urgent.xyz
|
paulb@35 | 127 | agenda/today.xyz
|
paulb@35 | 128 |
|
paulb@35 | 129 | This is somewhat counter-intuitive to typical Webware concepts, and it is
|
paulb@35 | 130 | recommended that Webware releases beyond 0.8.1 are used together with the
|
paulb@35 | 131 | appropriate WebStack context mechanisms instead of using this plug-in scheme.
|
paulb@35 | 132 |
|
paulb@444 | 133 | In order to support such behaviour, some patches must be applied to WebKit
|
paulb@444 | 134 | (with a suitable relative path to WebStack from Webware/WebKit):
|
paulb@35 | 135 |
|
paulb@35 | 136 | cd Webware/WebKit
|
paulb@35 | 137 | patch -p0 < ../../WebStack/patches/Webware/WebKit/Application.py-0.8.1.diff
|
paulb@35 | 138 | patch -p0 < ../../WebStack/patches/Webware/WebKit/HTTPRequest.py-0.8.1.diff
|
paulb@35 | 139 |
|
paulb@35 | 140 | Each plug-in, representing a WebStack application, should be visible in the
|
paulb@35 | 141 | Webware root directory. A symbolic link can be used to make each example
|
paulb@35 | 142 | appear; the Simple application being installed as follows:
|
paulb@21 | 143 |
|
paulb@21 | 144 | cd Webware
|
paulb@40 | 145 | ln -s ../WebStack/examples/Webware/SimpleApp
|
paulb@21 | 146 |
|
paulb@116 | 147 | Configuring the application server:
|
paulb@116 | 148 |
|
paulb@116 | 149 | Ensure that the ExtraPathInfo parameter in WebKit/Configs/Application.config
|
paulb@116 | 150 | is set to 0.
|
paulb@116 | 151 |
|
paulb@35 | 152 | Running the application server:
|
paulb@35 | 153 |
|
paulb@19 | 154 | Change into the WebKit directory within Webware. Then, specifying the
|
paulb@19 | 155 | appropriate PYTHONPATH, invoke the application server. For example:
|
paulb@19 | 156 |
|
paulb@19 | 157 | PYTHONPATH=../../WebStack:../../WebStack/examples/Common ./AppServer
|
paulb@19 | 158 |
|
paulb@19 | 159 | The WebStack package must reside on the PYTHONPATH, along with the package
|
paulb@19 | 160 | containing the application itself.
|