40#ifndef __AuthenticatedUser_h
41#define __AuthenticatedUser_h
45#include <DoubleList.h>
64extern BA_API
const char BasicAuthUser_derivedType[];
65extern BA_API
const char DigestAuthUser_derivedType[];
66extern BA_API
const char FormAuthUser_derivedType[];
85 AuthenticatedUserType_Unknown,
86 AuthenticatedUserType_Digest,
87 AuthenticatedUserType_Basic,
88 AuthenticatedUserType_Form
142#define AuthorizerIntf_constructor(o, authorize) (o)->authorizeFP=authorize
146#define AuthorizerIntf_authorize(o, user, method, path) \
147 (o)->authorizeFP(o, user, method, path)
218#define UserIntf_constructor(o, getPwd) (o)->getPwdFp = getPwd
224#define UserIntf_getPwd(o, username) (o)->getPwdFp(o, username)
227inline UserIntf::UserIntf(
235typedef struct AuthUserList
249BA_API
int AuthUserList_createOrCheck(
struct AuthInfo* info,
255typedef DoubleListEnumerator AuthUserListEnumerator;
256#define AuthUserListEnumerator_constructor(e, o) \
257 DoubleListEnumerator_constructor(e, &(o)->list)
259AuthUserListEnumerator_getElement(DoubleListEnumerator* o);
261AuthUserListEnumerator_nextElement(DoubleListEnumerator* o);
262void AuthUserList_termIfEmpty(AuthUserList* o);
323 void logout(
bool all=
false);
339 AuthUserList* authUserList;
340 const char* derivedType;
349 const char* derivedType,
362#define AuthenticatedUser_getName(o) \
363 ((o) && (o)->authUserList && (o)->authUserList->username ? \
364 (o)->authUserList->username : 0)
365#define AuthenticatedUser_getDerivedType(o) (o)->derivedType
369#define AuthenticatedUser_getSession(o) \
370 HttpSessionAttribute_getSession((HttpSessionAttribute*)o)
374#define AuthenticatedUser_getPassword(o) \
375 ((o) && (o)->authUserList && (o)->authUserList->password ? \
376 (o)->authUserList->password : 0)
454#define AuthenticatorIntf_authenticate(o, relPath, cmd) \
455 (o)->authenticateCB(o, relPath, cmd)
466inline AuthenticatorIntf::AuthenticatorIntf(
520#define LoginRespIntf_constructor(o, service) (o)->serviceFp=service
579 AuthUserList* authUserList;
617#define AuthInfo_constructor(o, trackerMA, cmdMA, typeMA) do {\
618 memset(o, 0, sizeof(AuthInfo));\
619 (o)->tracker=trackerMA;\
623 (o)->ct=AuthInfoCT_Password;\
729#define LoginTrackerIntf_constructor(\
730 o, validateMA, loginMA, loginFailedMA, terminateNodeMA) do {\
731 (o)->validate=validateMA;\
733 (o)->loginFailed=loginFailedMA;\
734 (o)->terminateNode=terminateNodeMA;\
742#define LoginTrackerIntf_validate(o, request, node) \
743 (o)->validate(o, request, node)
749#define LoginTrackerIntf_login(o, request, user) \
750 (o)->login(o, request, user)
756#define LoginTrackerIntf_loginFailed(o, node, loginName) \
757 (o)->loginFailed(o, node, loginName)
762#define LoginTrackerIntf_terminateNode(o, node) \
763 (o)->terminateNode(o, node)
830#define LoginTrackerNode_getCounter(o) (o)->loginCounter
834#define LoginTrackerNode_getAuxCounter(o) (o)->auxCounter
838#define LoginTrackerNode_setAuxCounter(o, count) (o)->auxCounter=count
842#define LoginTrackerNode_getAddr(o) (&(o)->addr)
846#define LoginTrackerNode_setUserData(o, data) (o)->userData=data
850#define LoginTrackerNode_getUserData(o) (o)->userData
854#define LoginTrackerNode_getTime(o) (o)->t
935 DoubleList dInUseList;
936 DoubleList dFreeList;
939 U32 noOfLoginTrackerNodes;
951 U32 noOfLoginTrackerNodes,
1025void calculateHA1Hex(
1026 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:218
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:530
LoginTrackerNode * find(HttpRequest *request)
Find a cached address using the current connection's peer IP.
Definition: AuthenticatedUser.h:1016
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:729
HttpSession * getSession()
Get the containing session.
Definition: AuthenticatedUser.h:396
static AuthenticatedUser * getAnonymous()
Access the shared anonymous user.
Definition: AuthenticatedUser.h:404
bool authorize(struct AuthenticatedUser *user, HttpMethod method, const char *path)
Returns TRUE if user is authorized.
Definition: AuthenticatedUser.h:154
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:842
const char * getPassword()
Access the stored credential representation.
Definition: AuthenticatedUser.h:398
AuthenticatedUser *(* AuthenticatorIntf_Authenticate)(struct AuthenticatorIntf *super, const char *relPath, HttpCommand *cmd)
The authenticator callback method for the abstract class AuthenticatorIntf.
Definition: AuthenticatedUser.h:416
U32 getCounter()
Query the address failure/denial counter.
Definition: AuthenticatedUser.h:857
LoginTrackerIntf(LoginTrackerIntf_Validate validate, LoginTrackerIntf_Login login, LoginTrackerIntf_LoginFailed loginFailed, LoginTrackerIntf_TerminateNode terminateNode)
Install four required callbacks; none may be NULL.
Definition: AuthenticatedUser.h:766
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:655
BaTime getTime()
Query the latest recorded failed or denied attempt.
Definition: AuthenticatedUser.h:877
BA_API AuthenticatedUser * AuthenticatedUser_get2(HttpSession *session)
Find the authenticated-user session attribute.
#define LoginTrackerNode_getUserData(o)
Query application data.
Definition: AuthenticatedUser.h:850
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:1013
#define AuthenticatorIntf_authenticate(o, relPath, cmd)
Authenticate the user.
Definition: AuthenticatedUser.h:454
void * getUserData()
Query application data.
Definition: AuthenticatedUser.h:874
AuthenticatedUserType getType()
Identify the authenticator that created this user.
Definition: AuthenticatedUser.h:402
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:641
AuthenticatedUser * authenticate(const char *relPath, HttpCommand *cmd)
Authenticate the user.
Definition: AuthenticatedUser.h:470
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:394
#define LoginRespIntf_constructor(o, service)
Install the callback used by LoginRespIntf.
Definition: AuthenticatedUser.h:520
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:1010
#define AuthenticatedUser_getSession(o)
Get the containing session.
Definition: AuthenticatedUser.h:369
#define LoginTrackerNode_getAuxCounter(o)
Query the application auxiliary counter.
Definition: AuthenticatedUser.h:834
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:830
void logout(bool all=false)
Log out and terminate the associated session or sessions.
Definition: AuthenticatedUser.h:400
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:493
void(* UserIntf_GetPwd)(struct UserIntf *intf, struct AuthInfo *info)
User database callback used by authenticators.
Definition: AuthenticatedUser.h:189
static AuthenticatedUser * get(HttpRequest *request)
Find the authenticated user without creating a session.
Definition: AuthenticatedUser.h:390
#define AuthorizerIntf_constructor(o, authorize)
Install the callback used by AuthorizerIntf.
Definition: AuthenticatedUser.h:142
void setUserData(void *data)
Associate application data with the node.
Definition: AuthenticatedUser.h:871
void clearCache()
Remove all active cached addresses.
Definition: AuthenticatedUser.h:1007
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:677
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:854
U32 getAuxCounter()
Query the application auxiliary counter.
Definition: AuthenticatedUser.h:860
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:868
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:374
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:146
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:693
#define AuthenticatedUser_getName(o)
Access the authenticated name.
Definition: AuthenticatedUser.h:362
void setAuxCounter(U32 count)
Set the application auxiliary counter.
Definition: AuthenticatedUser.h:864
#define LoginTrackerNode_setUserData(o, data)
Associate application data with the node.
Definition: AuthenticatedUser.h:846
#define LoginTrackerNode_setAuxCounter(o, count)
Set the application auxiliary counter.
Definition: AuthenticatedUser.h:838
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:1002
@ AuthInfoCT_Invalid
Set when getpwd callback failed comparing AuthInfo::upwd with stored password.
Definition: AuthenticatedUser.h:545
@ AuthInfoCT_Valid
Set when getpwd callback successfully compared AuthInfo::upwd with stored password.
Definition: AuthenticatedUser.h:540
@ AuthInfoCT_HA1
The password is returned as a HA1 hash, which is: MD5(username ":" realm ":" password)
Definition: AuthenticatedUser.h:536
@ AuthInfoCT_Password
The default.
Definition: AuthenticatedUser.h:532
void(* HttpSessionAttribute_Destructor)(struct HttpSessionAttribute *o)
HttpSessionAttribute termination callback function.
Definition: HttpServer.h:2248
HttpMethod
HTTP method types.
Definition: HttpServer.h:941
S64 BaTime
An arithmetic type representing calendar time with epoch of 1970-01-01 00:00:00 UTC,...
Definition: GenPrimT.h:106
uint32_t U32
Unsigned 32-bit integer.
Definition: GenPrimT.h:96
uint8_t U8
Unsigned 8-bit integer.
Definition: GenPrimT.h:92
U8 BaBool
Boolean stored in an unsigned byte; FALSE is zero and TRUE is one.
Definition: GenPrimT.h:121
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:554
const char * username
Borrowed NUL-terminated input user name, or NULL when no login was supplied.
Definition: AuthenticatedUser.h:562
const char * upwd
Borrowed supplied password when available for Basic/Form; NULL when unavailable, including Digest.
Definition: AuthenticatedUser.h:565
AuthInfoCT ct
Credential interpretation selected by UserIntf_GetPwd.
Definition: AuthenticatedUser.h:574
BaBool recycle
Initially FALSE.
Definition: AuthenticatedUser.h:604
int maxUsers
Maximum concurrent logins for the user; initially 3.
Definition: AuthenticatedUser.h:595
struct LoginTracker * tracker
Borrowed optional tracker; NULL when tracking is disabled.
Definition: AuthenticatedUser.h:556
U8 password[100]
Output credential storage, initially empty.
Definition: AuthenticatedUser.h:607
BaTime maxInactiveInterval
This variable specifies the time, in seconds, between client requests before the user is automaticall...
Definition: AuthenticatedUser.h:589
HttpCommand * cmd
Borrowed command for normal authentication.
Definition: AuthenticatedUser.h:559
AuthenticatedUser * user
Borrowed authenticated user when available, otherwise NULL.
Definition: AuthenticatedUser.h:568
int loginAttempts
Tracker-derived login counter difference when access is denied; initially zero.
Definition: AuthenticatedUser.h:598
BaBool denied
Initially FALSE; set TRUE when the tracker validation callback denies a cached address.
Definition: AuthenticatedUser.h:601
void * userObj
Application pointer shared between callbacks in this authentication flow; initially NULL.
Definition: AuthenticatedUser.h:577
AuthenticatedUserType type
Input authentication mechanism; Unknown is permitted for direct database lookup.
Definition: AuthenticatedUser.h:571
Abstract base class implemented by BasicAuthUser, FormAuthUser and DigestAuthUser.
Definition: AuthenticatedUser.h:273
Abstract interface class implemented by DigestAuthenticator, FormAuthenticator and BasicAuthenticator...
Definition: AuthenticatedUser.h:426
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:2179
The HttpServer creates an HttpRequest object when the HttpServer parses a client request.
Definition: HttpServer.h:981
Route and process HTTP requests using a borrowed dispatcher.
Definition: HttpServer.h:3463
The interface to an HttpSession attribute.
Definition: HttpServer.h:2279
Provides a way to identify a user across more than one page request or visit to a web site,...
Definition: HttpServer.h:2338
The LoginRespIntf is an abstract class, which must be implemented when using one of DigestAuthenticat...
Definition: AuthenticatedUser.h:505
The interface between the LoginTracker and the application code.
Definition: AuthenticatedUser.h:703
A LoginTrackerNode keeps track of how many times a user using a specific IP address has attempted to ...
Definition: AuthenticatedUser.h:781
The LoginTracker class is an optional security enhancement that can be installed in an instance of on...
Definition: AuthenticatedUser.h:892
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:196