forked from avih/miniweb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
httpauth.c
34 lines (32 loc) · 1.04 KB
/
httpauth.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/////////////////////////////////////////////////////////////////////////////
//
// httpauth.c
//
// MiniWeb HTTP authentication implementation
// Copyright (c) 2005-2012 Stanley Huang <[email protected]>
//
/////////////////////////////////////////////////////////////////////////////
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "httppil.h"
#include "httpapi.h"
#include "httpint.h"
////////////////////////////////////////////////////////////////////////////
// _mwCheckAuthentication
// Check if a connected peer is authenticated
////////////////////////////////////////////////////////////////////////////
BOOL _mwCheckAuthentication(HttpParam *hp, HttpSocket* phsSocket)
{
if (!ISFLAGSET(phsSocket,FLAG_AUTHENTICATION))
return TRUE;
if (hp->dwAuthenticatedNode != phsSocket->ipAddr.laddr) {
// Not authenticated
hp->stats.authFailCount++;
return FALSE;
}
// Extend authentication period
hp->tmAuthExpireTime = time(NULL) + HTTPAUTHTIMEOUT;
return TRUE;
}