40#ifndef __AuthenticatedUser_h
41#define __AuthenticatedUser_h
45#include <DoubleList.h>
64extern const char BasicAuthUser_derivedType[];
65extern const char DigestAuthUser_derivedType[];
66extern const char FormAuthUser_derivedType[];
85 AuthenticatedUserType_Unknown,
86 AuthenticatedUserType_Digest,
87 AuthenticatedUserType_Basic,
88 AuthenticatedUserType_Form
141#define AuthorizerIntf_constructor(o, authorize) (o)->authorizeFP=authorize
145#define AuthorizerIntf_authorize(o, user, method, path) \
146 (o)->authorizeFP(o, user, method, path)
217#define UserIntf_constructor(o, getPwd) (o)->getPwdFp = getPwd
223#define UserIntf_getPwd(o, username) (o)->getPwdFp(o, username)
226inline UserIntf::UserIntf(
234typedef struct AuthUserList
248BA_API
int AuthUserList_createOrCheck(
struct AuthInfo* info,
254typedef DoubleListEnumerator AuthUserListEnumerator;
255#define AuthUserListEnumerator_constructor(e, o) \
256 DoubleListEnumerator_constructor(e, &(o)->list)
258AuthUserListEnumerator_getElement(DoubleListEnumerator* o);
260AuthUserListEnumerator_nextElement(DoubleListEnumerator* o);
261void AuthUserList_termIfEmpty(AuthUserList* o);
322 void logout(
bool all=
false);
338 AuthUserList* authUserList;
339 const char* derivedType;
348 const char* derivedType,
361#define AuthenticatedUser_getName(o) \
362 ((o) && (o)->authUserList && (o)->authUserList->username ? \
363 (o)->authUserList->username : 0)
364#define AuthenticatedUser_getDerivedType(o) (o)->derivedType
368#define AuthenticatedUser_getSession(o) \
369 HttpSessionAttribute_getSession((HttpSessionAttribute*)o)
373#define AuthenticatedUser_getPassword(o) \
374 ((o) && (o)->authUserList && (o)->authUserList->password ? \
375 (o)->authUserList->password : 0)
453#define AuthenticatorIntf_authenticate(o, relPath, cmd) \
454 (o)->authenticateCB(o, relPath, cmd)
465inline AuthenticatorIntf::AuthenticatorIntf(
519#define LoginRespIntf_constructor(o, service) (o)->serviceFp=service
578 AuthUserList* authUserList;
616#define AuthInfo_constructor(o, trackerMA, cmdMA, typeMA) do {\
617 memset(o, 0, sizeof(AuthInfo));\
618 (o)->tracker=trackerMA;\
622 (o)->ct=AuthInfoCT_Password;\
728#define LoginTrackerIntf_constructor(\
729 o, validateMA, loginMA, loginFailedMA, terminateNodeMA) do {\
730 (o)->validate=validateMA;\
732 (o)->loginFailed=loginFailedMA;\
733 (o)->terminateNode=terminateNodeMA;\
741#define LoginTrackerIntf_validate(o, request, node) \
742 (o)->validate(o, request, node)
748#define LoginTrackerIntf_login(o, request, user) \
749 (o)->login(o, request, user)
755#define LoginTrackerIntf_loginFailed(o, node, loginName) \
756 (o)->loginFailed(o, node, loginName)
761#define LoginTrackerIntf_terminateNode(o, node) \
762 (o)->terminateNode(o, node)
829#define LoginTrackerNode_getCounter(o) (o)->loginCounter
833#define LoginTrackerNode_getAuxCounter(o) (o)->auxCounter
837#define LoginTrackerNode_setAuxCounter(o, count) (o)->auxCounter=count
841#define LoginTrackerNode_getAddr(o) (&(o)->addr)
845#define LoginTrackerNode_setUserData(o, data) (o)->userData=data
849#define LoginTrackerNode_getUserData(o) (o)->userData
853#define LoginTrackerNode_getTime(o) (o)->t
934 DoubleList dInUseList;
935 DoubleList dFreeList;
938 U32 noOfLoginTrackerNodes;
950 U32 noOfLoginTrackerNodes,
1024void calculateHA1Hex(
1025 const char* realm,
const char* uname,
const char* pwd,
U8 hexbuf[33]);
#define UserIntf_constructor(o, getPwd)
Install the callback used by UserIntf.
Definition: AuthenticatedUser.h:217
struct UserIntf UserIntf
User database interface used by the authentication classes.
AuthInfoCT
AuthInfo Credential Type can optionally be used by the UserIntf_GetPwd callback function.
Definition: AuthenticatedUser.h:529
LoginTrackerNode * find(HttpRequest *request)
Find a cached address using the current connection's peer IP.
Definition: AuthenticatedUser.h:1015
BA_API void LoginTracker_loginFailed(LoginTracker *o, AuthInfo *info)
Record a failed login, inserting or recycling an address node as needed.
#define LoginTrackerIntf_constructor(o, validateMA, loginMA, loginFailedMA, terminateNodeMA)
Install required tracker callbacks; no callback may be NULL.
Definition: AuthenticatedUser.h:728
HttpSession * getSession()
Get the containing session.
Definition: AuthenticatedUser.h:395
static AuthenticatedUser * getAnonymous()
Access the shared anonymous user.
Definition: AuthenticatedUser.h:403
bool authorize(struct AuthenticatedUser *user, HttpMethod method, const char *path)
Returns TRUE if user is authorized.
Definition: AuthenticatedUser.h:153
BA_API void AuthenticatedUser_logout(AuthenticatedUser *o, BaBool all)
Log out and terminate the associated session or sessions.
#define LoginTrackerNode_getAddr(o)
Access the cached peer IP address.
Definition: AuthenticatedUser.h:841
const char * getPassword()
Access the stored credential representation.
Definition: AuthenticatedUser.h:397
AuthenticatedUser *(* AuthenticatorIntf_Authenticate)(struct AuthenticatorIntf *super, const char *relPath, HttpCommand *cmd)
The authenticator callback method for the abstract class AuthenticatorIntf.
Definition: AuthenticatedUser.h:415
U32 getCounter()
Query the address failure/denial counter.
Definition: AuthenticatedUser.h:856
LoginTrackerIntf(LoginTrackerIntf_Validate validate, LoginTrackerIntf_Login login, LoginTrackerIntf_LoginFailed loginFailed, LoginTrackerIntf_TerminateNode terminateNode)
Install four required callbacks; none may be NULL.
Definition: AuthenticatedUser.h:765
BA_API LoginTrackerNode * LoginTracker_getNextNode(LoginTracker *o, LoginTrackerNode *n)
Advance through active cached addresses.
void(* LoginTrackerIntf_Login)(struct LoginTrackerIntf *o, AuthInfo *info, struct LoginTrackerNode *node)
Prototype for the Login tracker method.
Definition: AuthenticatedUser.h:654
BaTime getTime()
Query the latest recorded failed or denied attempt.
Definition: AuthenticatedUser.h:876
BA_API AuthenticatedUser * AuthenticatedUser_get2(HttpSession *session)
Find the authenticated-user session attribute.
#define LoginTrackerNode_getUserData(o)
Query application data.
Definition: AuthenticatedUser.h:849
struct AuthorizerIntf AuthorizerIntf
An abstract class, which you must implement, provides a method of authorizing an authenticated user.
LoginTrackerNode * getNextNode(LoginTrackerNode *n)
Advance through active cached addresses.
Definition: AuthenticatedUser.h:1012
#define AuthenticatorIntf_authenticate(o, relPath, cmd)
Authenticate the user.
Definition: AuthenticatedUser.h:453
void * getUserData()
Query application data.
Definition: AuthenticatedUser.h:873
AuthenticatedUserType getType()
Identify the authenticator that created this user.
Definition: AuthenticatedUser.h:401
struct AuthenticatorIntf AuthenticatorIntf
Abstract interface class implemented by DigestAuthenticator, FormAuthenticator and BasicAuthenticator...
BaBool(* LoginTrackerIntf_Validate)(struct LoginTrackerIntf *o, AuthInfo *info, struct LoginTrackerNode *node)
Prototype for the validate callback method.
Definition: AuthenticatedUser.h:640
AuthenticatedUser * authenticate(const char *relPath, HttpCommand *cmd)
Authenticate the user.
Definition: AuthenticatedUser.h:469
struct LoginTrackerNode LoginTrackerNode
A LoginTrackerNode keeps track of how many times a user using a specific IP address has attempted to ...
BA_API BaBool LoginTracker_validate(LoginTracker *o, AuthInfo *info)
Check whether a cached peer may attempt authentication.
BA_API void LoginTracker_login(LoginTracker *o, AuthInfo *info)
Notify successful authentication and remove any cached peer entry.
BA_API AuthenticatedUser * AuthenticatedUser_get1(HttpRequest *request)
Find the authenticated user without creating a session.
const char * getName()
Access the authenticated name.
Definition: AuthenticatedUser.h:393
#define LoginRespIntf_constructor(o, service)
Install the callback used by LoginRespIntf.
Definition: AuthenticatedUser.h:519
BA_API void LoginTracker_destructor(LoginTracker *o)
Release a tracker after detaching all users.
LoginTrackerNode * getFirstNode()
Start iteration over active cached addresses in insertion order.
Definition: AuthenticatedUser.h:1009
#define AuthenticatedUser_getSession(o)
Get the containing session.
Definition: AuthenticatedUser.h:368
#define LoginTrackerNode_getAuxCounter(o)
Query the application auxiliary counter.
Definition: AuthenticatedUser.h:833
AuthenticatedUserType
The authenticator types.
Definition: AuthenticatedUser.h:84
struct LoginRespIntf LoginRespIntf
The LoginRespIntf is an abstract class, which must be implemented when using one of DigestAuthenticat...
#define LoginTrackerNode_getCounter(o)
Query the address failure/denial counter.
Definition: AuthenticatedUser.h:829
void logout(bool all=false)
Log out and terminate the associated session or sessions.
Definition: AuthenticatedUser.h:399
struct LoginTrackerIntf LoginTrackerIntf
The interface between the LoginTracker and the application code.
void(* LoginRespIntf_Service)(struct LoginRespIntf *intf, struct AuthInfo *info)
This callback function is called if the user failed to authenticate with one of DigestAuthenticator,...
Definition: AuthenticatedUser.h:492
void(* UserIntf_GetPwd)(struct UserIntf *intf, struct AuthInfo *info)
User database callback used by authenticators.
Definition: AuthenticatedUser.h:188
static AuthenticatedUser * get(HttpRequest *request)
Find the authenticated user without creating a session.
Definition: AuthenticatedUser.h:389
#define AuthorizerIntf_constructor(o, authorize)
Install the callback used by AuthorizerIntf.
Definition: AuthenticatedUser.h:141
void setUserData(void *data)
Associate application data with the node.
Definition: AuthenticatedUser.h:870
void clearCache()
Remove all active cached addresses.
Definition: AuthenticatedUser.h:1006
struct LoginTracker LoginTracker
The LoginTracker class is an optional security enhancement that can be installed in an instance of on...
BA_API LoginTrackerNode * LoginTracker_getFirstNode(LoginTracker *o)
Start iteration over active cached addresses in insertion order.
void(* LoginTrackerIntf_LoginFailed)(struct LoginTrackerIntf *o, AuthInfo *info, struct LoginTrackerNode *node)
Prototype for the LoginFailed callback method.
Definition: AuthenticatedUser.h:676
BA_API AuthenticatedUser * AuthenticatedUser_getAnonymous(void)
Access the shared anonymous user.
#define LoginTrackerNode_getTime(o)
Query the latest recorded failed or denied attempt.
Definition: AuthenticatedUser.h:853
U32 getAuxCounter()
Query the application auxiliary counter.
Definition: AuthenticatedUser.h:859
struct AuthInfo AuthInfo
An instance of the AuthInfo struct is created on the stack in the Barracuda authenticators and is use...
BA_API AuthenticatedUserType AuthenticatedUser_getType(AuthenticatedUser *o)
Identify the authenticator that created this user.
HttpSockaddr * getAddr()
Access the cached peer IP address.
Definition: AuthenticatedUser.h:867
BaBool(* AuthorizerIntf_Authorize)(struct AuthorizerIntf *intf, struct AuthenticatedUser *user, HttpMethod httpMethod, const char *path)
Prototype for the Authorize callback method.
Definition: AuthenticatedUser.h:105
#define AuthenticatedUser_getPassword(o)
Access the stored credential representation.
Definition: AuthenticatedUser.h:373
struct AuthenticatedUser AuthenticatedUser
Abstract base class implemented by BasicAuthUser, FormAuthUser and DigestAuthUser.
#define AuthorizerIntf_authorize(o, user, method, path)
Returns TRUE if user is authorized.
Definition: AuthenticatedUser.h:145
BA_API void LoginTracker_clearCache(LoginTracker *o)
Remove all active cached addresses.
void(* LoginTrackerIntf_TerminateNode)(struct LoginTrackerIntf *o, struct LoginTrackerNode *node)
Prototype for the TerminateNode callback method.
Definition: AuthenticatedUser.h:692
#define AuthenticatedUser_getName(o)
Access the authenticated name.
Definition: AuthenticatedUser.h:361
void setAuxCounter(U32 count)
Set the application auxiliary counter.
Definition: AuthenticatedUser.h:863
#define LoginTrackerNode_setUserData(o, data)
Associate application data with the node.
Definition: AuthenticatedUser.h:845
#define LoginTrackerNode_setAuxCounter(o, count)
Set the application auxiliary counter.
Definition: AuthenticatedUser.h:837
BA_API void AuthenticatorIntf_constructor(AuthenticatorIntf *o, AuthenticatorIntf_Authenticate authenticate)
Install the callback used by AuthenticatorIntf.
BA_API LoginTrackerNode * LoginTracker_find(LoginTracker *o, HttpRequest *req)
C form of LoginTracker::find.
BA_API void LoginTracker_constructor(LoginTracker *o, U32 noOfLoginTrackerNodes, LoginTrackerIntf *intf, AllocatorIntf *allocator)
Allocate a fixed cache of address records.
LoginTracker(U32 noOfLoginTrackerNodes, LoginTrackerIntf *intf, AllocatorIntf *allocator=AllocatorIntf::getDefault())
Allocate a fixed cache of address records.
Definition: AuthenticatedUser.h:1001
@ AuthInfoCT_Invalid
Set when getpwd callback failed comparing AuthInfo::upwd with stored password.
Definition: AuthenticatedUser.h:544
@ AuthInfoCT_Valid
Set when getpwd callback successfully compared AuthInfo::upwd with stored password.
Definition: AuthenticatedUser.h:539
@ AuthInfoCT_HA1
The password is returned as a HA1 hash, which is: MD5(username ":" realm ":" password)
Definition: AuthenticatedUser.h:535
@ AuthInfoCT_Password
The default.
Definition: AuthenticatedUser.h:531
void(* HttpSessionAttribute_Destructor)(struct HttpSessionAttribute *o)
HttpSessionAttribute termination callback function.
Definition: HttpServer.h:2216
HttpMethod
HTTP method types.
Definition: HttpServer.h:910
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:103
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:93
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:89
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:118
Memory allocation and deallocation Interface class.
Definition: AllocatorIntf.h:98
static AllocatorIntf * getDefault(void)
Obtain the shared allocator backed by baMalloc, baRealloc and baFree.
Definition: AllocatorIntf.h:200
An instance of the AuthInfo struct is created on the stack in the Barracuda authenticators and is use...
Definition: AuthenticatedUser.h:553
const char * username
Borrowed NUL-terminated input user name, or NULL when no login was supplied.
Definition: AuthenticatedUser.h:561
const char * upwd
Borrowed supplied password when available for Basic/Form; NULL when unavailable, including Digest.
Definition: AuthenticatedUser.h:564
AuthInfoCT ct
Credential interpretation selected by UserIntf_GetPwd.
Definition: AuthenticatedUser.h:573
BaBool recycle
Initially FALSE.
Definition: AuthenticatedUser.h:603
int maxUsers
Maximum concurrent logins for the user; initially 3.
Definition: AuthenticatedUser.h:594
struct LoginTracker * tracker
Borrowed optional tracker; NULL when tracking is disabled.
Definition: AuthenticatedUser.h:555
U8 password[100]
Output credential storage, initially empty.
Definition: AuthenticatedUser.h:606
BaTime maxInactiveInterval
This variable specifies the time, in seconds, between client requests before the user is automaticall...
Definition: AuthenticatedUser.h:588
HttpCommand * cmd
Borrowed command for normal authentication.
Definition: AuthenticatedUser.h:558
AuthenticatedUser * user
Borrowed authenticated user when available, otherwise NULL.
Definition: AuthenticatedUser.h:567
int loginAttempts
Tracker-derived login counter difference when access is denied; initially zero.
Definition: AuthenticatedUser.h:597
BaBool denied
Initially FALSE; set TRUE when the tracker validation callback denies a cached address.
Definition: AuthenticatedUser.h:600
void * userObj
Application pointer shared between callbacks in this authentication flow; initially NULL.
Definition: AuthenticatedUser.h:576
AuthenticatedUserType type
Input authentication mechanism; Unknown is permitted for direct database lookup.
Definition: AuthenticatedUser.h:570
Abstract base class implemented by BasicAuthUser, FormAuthUser and DigestAuthUser.
Definition: AuthenticatedUser.h:272
Abstract interface class implemented by DigestAuthenticator, FormAuthenticator and BasicAuthenticator...
Definition: AuthenticatedUser.h:425
An abstract class, which you must implement, provides a method of authorizing an authenticated user.
Definition: AuthenticatedUser.h:115
The HttpCommand class is a container class for the HttpRequest and HttpResponse command pair.
Definition: HttpServer.h:2151
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:950
The Web Server.
Definition: HttpServer.h:3393
The interface to an HttpSession attribute.
Definition: HttpServer.h:2247
Provides a way to identify a user across more than one page request or visit to a web site,...
Definition: HttpServer.h:2305
The LoginRespIntf is an abstract class, which must be implemented when using one of DigestAuthenticat...
Definition: AuthenticatedUser.h:504
The interface between the LoginTracker and the application code.
Definition: AuthenticatedUser.h:702
A LoginTrackerNode keeps track of how many times a user using a specific IP address has attempted to ...
Definition: AuthenticatedUser.h:780
The LoginTracker class is an optional security enhancement that can be installed in an instance of on...
Definition: AuthenticatedUser.h:891
Intrusive tree node.
Definition: SplayTree.h:52
Self-adjusting tree of caller-owned nodes, with unique keys.
Definition: SplayTree.h:109
User database interface used by the authentication classes.
Definition: AuthenticatedUser.h:195