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