4 * FastCGI example Authorizer program using fcgi_stdio library
7 * Be sure to run this program in a region with CGIPassword
8 * in order to get REMOTE_USER and REMOTE_PASSWD in place
9 * of HTTP_AUTHORIZATION.
11 * Copyright (c) 1996 Open Market, Inc.
13 * See the file "LICENSE.TERMS" for information on usage and redistribution
14 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
19 static const char rcsid[] = "$Id: tiny-authorizer.c,v 1.1 1997/09/16 15:36:28 stanleyg Exp $";
22 #include "fcgi_stdio.h"
28 char *user, *password;
29 user = getenv("USER");
33 password = getenv("PASSWORD");
34 if(password == NULL) {
38 while(FCGI_Accept() >= 0) {
39 char *remoteUser, *remotePassword;
40 remoteUser = getenv("REMOTE_USER");
41 remotePassword = getenv("REMOTE_PASSWD");
42 if((remoteUser == NULL) || (remotePassword == NULL) ||
43 strcmp(remoteUser, user) || strcmp(remotePassword, password)) {
44 printf("Status: 401 Unauthorized\r\n"
45 "WWW-Authenticate: Basic realm=\"Test\"\r\n"
49 char *processId = getenv("QUERY_STRING");
50 if(processId == NULL || strlen(processId) == 0) {
53 printf("Status: 200 OK\r\n"
54 "Variable-AUTH_TYPE: Basic\r\n"
55 "Variable-REMOTE_PASSWD:\r\n"
56 "Variable-PROCESS_ID: %s\r\n"