4 * FastCGI example Authorizer program using fcgi_stdio library
6 * Copyright (c) 1996 Open Market, Inc.
7 * See the file "LICENSE" for information on usage and redistribution
8 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
10 * $Id: authorizer.c,v 1.1 2001/06/19 15:30:02 robs Exp $
13 #include "fcgi_stdio.h"
19 char *user, *password;
21 user = getenv("USER");
26 password = getenv("PASSWORD");
27 if (password == NULL) {
31 while (FCGI_Accept() >= 0) {
32 char *remoteUser, *remotePassword;
34 remoteUser = getenv("REMOTE_USER");
35 remotePassword = getenv("REMOTE_PASSWD");
36 if ((remoteUser == NULL) || (remotePassword == NULL)
37 || strcmp(remoteUser, user) || strcmp(remotePassword, password))
39 printf("Status: 401 Unauthorized\r\n"
40 "WWW-Authenticate: Basic realm=\"Test\"\r\n"
44 char *processId = getenv("QUERY_STRING");
45 if (processId == NULL || strlen(processId) == 0) {
48 printf("Status: 200 OK\r\n"
49 "Variable-AUTH_TYPE: Basic\r\n"
50 "Variable-REMOTE_PASSWD:\r\n"
51 "Variable-PROCESS_ID: %s\r\n"