websSecurityHandler GoAhead WebServer API GoAhead EMF

Synopsis

URL handler for the default security policy.

Prototype

 #include "webs.h" 

 int websSecurityHandler(webs_t wp, char_t *url, char_t *path, char_t *query); 

Parameters

wp Web server connection handle.
url Request URL.
path Request path portion of the URL.
query Query string portion of the URL.

Description

websSecurityHandler implements the default security policy. It operates as a URL handler and is installed to run as the very first URL handler. If you require a replacement security policy, delete the websSecurityHandler and install your own with websUrlHandlerDefine.

The websSetPassword procedure defines the security password. The security handler will require all non-local requests (those from a remote system) to supply this password. The user name is ignored. To use the password feature, the Security Handler must be installed by calling websHandlerDefine for websSecurityHandler. This in done automatically in the GoAhead EMF. If you are using the GoAhead WebServer, this should be done in your main program. See main.c for examples.

The security handler should return 0 if the request is acceptable. It should return 1 to deny the request. When websSecurityHandler denies a request, it first returns a 401 response code to cause the user's browser to prompt for a username and password.

Use websGetRequestPassword to get the password supplied with the current request.

Return Value

Returns 0 if the request is acceptable. Returns 1 if the request is denied.

Example

The following code will install a new security handler:

 websSecurityDelete(); 
websUrlHandlerDefine("", mySecurityHandler, WEBS_HANDLER_FIRST); 

Stability Classification

Stable.

See Also

websGetRequestFlags, websGetRequestIpaddr, websGetRequestPassword, websGetRequestType