UserRequest.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2019 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_AUTH_USERREQUEST_H
10 #define SQUID_AUTH_USERREQUEST_H
11 
12 #if USE_AUTH
13 
14 #include "AccessLogEntry.h"
15 #include "auth/AuthAclState.h"
16 #include "auth/Scheme.h"
17 #include "auth/User.h"
18 #include "dlink.h"
19 #include "helper/forward.h"
20 #include "HttpHeader.h"
21 #include "ip/Address.h"
22 
23 class ConnStateData;
24 class HttpReply;
25 class HttpRequest;
26 
30 // XXX: Keep in sync with all others: bzr grep 'define MAX_AUTHTOKEN_LEN'
31 #define MAX_AUTHTOKEN_LEN 65535
32 
38 {
40 
41 public:
42  AuthUserIP(const Ip::Address &ip, time_t t) : ipaddr(ip), ip_expiretime(t) {}
43 
45 
48 
53  time_t ip_expiretime;
54 };
55 
56 // TODO: make auth schedule AsyncCalls?
57 typedef void AUTHCB(void*);
58 
59 namespace Auth
60 {
61 
62 // NP: numeric values specified for old code backward compatibility.
63 // remove after transition is complete
64 enum Direction {
66  CRED_VALID = 0,
67  CRED_LOOKUP = -1,
68  CRED_ERROR = -2
69 };
70 
77 class UserRequest : public RefCountable
78 {
79 public:
81 
82  UserRequest();
83  virtual ~UserRequest();
84  void *operator new(size_t byteCount);
85  void operator delete(void *address);
86 
87 public:
94 
107  Direction direction();
108 
115  virtual int authenticated() const = 0;
116 
127  bool valid() const;
128 
130 
131  /* template method - what needs to be done next? advertise schemes, challenge, handle error, nothing? */
132  virtual Direction module_direction() = 0;
133 
134  /* add the [Proxy-]Authentication-Info header */
135  virtual void addAuthenticationInfoHeader(HttpReply * rep, int accel);
136 
137  /* add the [Proxy-]Authentication-Info trailer */
138  virtual void addAuthenticationInfoTrailer(HttpReply * rep, int accel);
139 
140  virtual void releaseAuthServer();
141 
142  // User credentials object this UserRequest is managing
143  virtual User::Pointer user() {return _auth_user;}
144  virtual const User::Pointer user() const {return _auth_user;}
145  virtual void user(User::Pointer aUser) {_auth_user=aUser;}
146 
165  static AuthAclState tryToAuthenticateAndSetAuthUser(UserRequest::Pointer *aUR, Http::HdrType, HttpRequest *, ConnStateData *, Ip::Address &, AccessLogEntry::Pointer &);
166 
168  static void AddReplyAuthHeader(HttpReply * rep, UserRequest::Pointer auth_user_request, HttpRequest * request, int accelerated, int internal);
169 
180  void start(HttpRequest *request, AccessLogEntry::Pointer &al, AUTHCB *handler, void *data);
181 
182  char const * denyMessage(char const * const default_message = NULL) const;
183 
185  void setDenyMessage(char const *);
186 
188  char const * getDenyMessage() const;
189 
198  char const *username() const;
199 
200  Scheme::Pointer scheme() const;
201 
202  virtual const char * connLastHeader();
203 
207  virtual const char *credentialsStr() = 0;
208 
209  const char *helperRequestKeyExtras(HttpRequest *, AccessLogEntry::Pointer &al);
210 
212  void denyMessageFromHelper(char const *proto, const Helper::Reply &reply);
213 
214 protected:
220  virtual void startHelperLookup(HttpRequest *request, AccessLogEntry::Pointer &al, AUTHCB *handler, void *data) = 0;
221 
222 private:
223 
224  static AuthAclState authenticate(UserRequest::Pointer * auth_user_request, Http::HdrType headertype, HttpRequest * request, ConnStateData * conn, Ip::Address &src_addr, AccessLogEntry::Pointer &al);
225 
227  char *message;
228 
235 };
236 
237 } // namespace Auth
238 
239 /* AuthUserRequest */
240 
247 
251 
252 #endif /* USE_AUTH */
253 #endif /* SQUID_AUTHUSERREQUEST_H */
254 
virtual void user(User::Pointer aUser)
Definition: UserRequest.h:145
time_t ip_expiretime
Definition: UserRequest.h:53
int type
Definition: errorpage.cc:152
void authenticateAuthUserRequestRemoveIp(Auth::UserRequest::Pointer, Ip::Address const &)
Definition: UserRequest.cc:147
static void authenticate(int socket_fd, const char *username, const char *passwd)
AuthAclState
Definition: AuthAclState.h:14
struct _request * request(char *urlin)
Definition: tcp-banger2.c:291
int authenticateAuthUserRequestIPCount(Auth::UserRequest::Pointer)
Definition: UserRequest.cc:165
Direction
Definition: UserRequest.h:64
int conn
the current server connection FD
Definition: Transport.cc:26
int authenticateUserAuthenticated(Auth::UserRequest::Pointer)
Definition: UserRequest.cc:176
AuthAclState lastReply
Definition: UserRequest.h:234
Client needs to be challenged. secure token.
Definition: UserRequest.h:65
void const char HLPCB void * data
Definition: stub_helper.cc:16
dlink_node node
Definition: UserRequest.h:44
MEMPROXY_CLASS(AuthUserIP)
RefCount< Auth::UserRequest > Pointer
Definition: UserRequest.h:80
ERROR in the auth module. Cannot determine the state of this request.
Definition: UserRequest.h:68
static void handler(int signo)
Definition: purge.cc:860
Ip::Address ipaddr
IP address this user authenticated from.
Definition: UserRequest.h:47
Credentials are valid and a up to date. The OK/Failed state is accurate.
Definition: UserRequest.h:66
virtual User::Pointer user()
Definition: UserRequest.h:143
Credentials need to be validated with the backend helper.
Definition: UserRequest.h:67
AuthUserIP(const Ip::Address &ip, time_t t)
Definition: UserRequest.h:42
HTTP Authentication.
Definition: Config.h:18
virtual const User::Pointer user() const
Definition: UserRequest.h:144
void AUTHCB(void *)
Definition: UserRequest.h:57
#define NULL
Definition: types.h:166
User::Pointer _auth_user
Definition: UserRequest.h:93
void authenticateAuthUserRequestClearIp(Auth::UserRequest::Pointer)
Definition: UserRequest.cc:158

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors