AuthTrans Example
218
Netscape Enterprise Server NSAPI Programmer’s Guide • April 2002 (Draft)
Note that this function does not actually enforce authorization requirements, it
only takes given information and tells the server if it's correct or not. The
PathCheck
function
require-auth
performs the enforcement, so add the
following
PathCheck
directive also:
PathCheck fn=require-auth realm="test realm" auth-type="basic"
Source Code
The source code for this example is in the
auth.c
file in the
nsapi/examples/
or
plugins/nsapi/examples
subdirectory of the server root directory.
#include "nsapi.h"
typedef struct {
char *name;
char *pw;
} user_s;
static user_s user_set[] = {
{"joe", "shmoe"},
{"suzy", "creamcheese"},
{NULL, NULL}
};
#include "frame/log.h"
#ifdef __cplusplus
extern "C"
#endif
NSAPI_PUBLIC int hardcoded_auth(pblock *param, Session *sn, Request
*rq)
{
/* Parameters given to us by auth-basic */
char *pwfile = pblock_findval("userdb", param);
char *user = pblock_findval("user", param);
char *pw = pblock_findval("pw", param);
/* Temp variables */
register int x;
for(x = 0; user_set[x].name != NULL; ++x) {
/* If this isn't the user we want, keep going */
if(strcmp(user, user_set[x].name) != 0) continue;
Summary of Contents for ENTERPRISE SERVER 6.1
Page 1: ...NSAPI Programmer s Guide Netscape Enterprise Server Version6 1 April 2002 Draft...
Page 290: ...Miscellaneous 290 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 318: ...cinfo 318 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 336: ...Buffered Streams 336 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 344: ...344 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 350: ...350 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...
Page 356: ...356 Netscape Enterprise Server NSAPI Programmer s Guide April 2002 Draft...