3 * Internal declarations for the digest auth module
6 #ifndef __AUTH_DIGEST_H__
7 #define __AUTH_DIGEST_H__
9 #include "authenticate.h"
11 #include "AuthUserRequest.h"
12 #include "AuthConfig.h"
17 class DigestAuthenticateStateData
22 AuthUserRequest
*auth_user_request
;
26 typedef struct _digest_nonce_data digest_nonce_data
;
28 typedef struct _digest_nonce_h digest_nonce_h
;
30 class DigestUser
: public AuthUser
34 MEMPROXY_CLASS(DigestUser
);
36 DigestUser(AuthConfig
*);
38 int authenticated() const;
42 /* what nonces have been allocated to this user */
47 MEMPROXY_CLASS_INLINE(DigestUser
);
49 typedef class DigestUser digest_user_h
;
51 /* the digest_request structure is what follows the http_request around */
53 class AuthDigestUserRequest
: public AuthUserRequest
57 enum CredentialsState
{Unchecked
, Ok
, Pending
, Failed
};
58 MEMPROXY_CLASS(AuthDigestUserRequest
);
60 AuthDigestUserRequest();
61 virtual ~AuthDigestUserRequest();
63 virtual int authenticated() const;
64 virtual void authenticate(HttpRequest
* request
, ConnStateData
* conn
, http_hdr_type type
);
65 virtual int module_direction();
66 virtual void addHeader(HttpReply
* rep
, int accel
);
69 virtual void addTrailer(HttpReply
* rep
, int accel
);
72 virtual void module_start(RH
*, void *);
73 virtual AuthUser
*user() {return _theUser
;}
75 virtual const AuthUser
*user() const {return _theUser
;}
77 virtual void user(AuthUser
*aUser
) {_theUser
=dynamic_cast<DigestUser
*>(aUser
);}
79 CredentialsState
credentials() const;
80 void credentials(CredentialsState
);
82 void authUser(AuthUser
*);
83 AuthUser
*authUser() const;
85 char *nonceb64
; /* "dcd98b7102dd2f0e8b11d0f600bfb0c093" */
86 char *cnonce
; /* "0a4f113b" */
87 char *realm
; /* = "testrealm@host.com" */
88 char *pszPass
; /* = "Circle Of Life" */
89 char *algorithm
; /* = "md5" */
90 char nc
[9]; /* = "00000001" */
91 char *pszMethod
; /* = "GET" */
92 char *qop
; /* = "auth" */
93 char *uri
; /* = "/dir/index.html" */
98 unsigned int authinfo_sent
:1;
99 unsigned int invalid_password
:1;
100 unsigned int helper_queried
:1;
102 digest_nonce_h
*nonce
;
105 DigestUser
*_theUser
;
106 CredentialsState credentials_ok
;
109 MEMPROXY_CLASS_INLINE(AuthDigestUserRequest
) /**DOCS_NOSEMI*/
111 /* data to be encoded into the nonce's b64 representation */
113 struct _digest_nonce_data
116 /* in memory address of the nonce struct (similar purpose to an ETag) */
117 digest_nonce_h
*self
;
121 /* the nonce structure we'll pass around */
123 struct _digest_nonce_h
: public hash_link
125 digest_nonce_data noncedata
;
126 /* number of uses we've seen of this nonce */
128 /* reference count */
130 /* the auth_user this nonce has been tied to */
132 /* has this nonce been invalidated ? */
136 unsigned int valid
:1;
137 unsigned int incache
:1;
141 /* configuration runtime data */
143 class AuthDigestConfig
: public AuthConfig
148 virtual bool active() const;
149 virtual bool configured() const;
150 virtual AuthUserRequest
*decode(char const *proxy_auth
);
152 virtual void dump(StoreEntry
*, const char *, AuthConfig
*);
153 virtual void fixHeader(AuthUserRequest
*, HttpReply
*, http_hdr_type
, HttpRequest
*);
154 virtual void init(AuthConfig
*);
155 virtual void parse(AuthConfig
*, int, char *);
156 virtual void registerWithCacheManager(CacheManager
& manager
);
157 virtual const char * type() const;
158 int authenticateChildren
;
159 char *digestAuthRealm
;
160 wordlist
*authenticate
;
161 time_t nonceGCInterval
;
162 time_t noncemaxduration
;
163 unsigned int noncemaxuses
;
169 typedef class AuthDigestConfig auth_digest_config
;
172 #define QOP_AUTH "auth"