void
CacheManager::ParseHeaders(const HttpRequest * request, Mgr::ActionParams ¶ms)
{
- const char *basic_cookie; /* base 64 _decoded_ user:passwd pair */
- const char *passwd_del;
assert(request);
params.httpMethod = request->method.id();
params.httpFlags = request->flags;
- basic_cookie = request->header.getAuth(HDR_AUTHORIZATION, "Basic");
+#if HAVE_AUTH_MODULE_BASIC
+ // TODO: use the authentication system decode to retrieve these details properly.
+
+ /* base 64 _decoded_ user:passwd pair */
+ const char *basic_cookie = request->header.getAuth(HDR_AUTHORIZATION, "Basic");
if (!basic_cookie)
return;
+ const char *passwd_del;
if (!(passwd_del = strchr(basic_cookie, ':'))) {
debugs(16, DBG_IMPORTANT, "CacheManager::ParseHeaders: unknown basic_cookie format '" << basic_cookie << "'");
return;
params.userName.limitInit(basic_cookie, passwd_del - basic_cookie);
params.password = passwd_del + 1;
- /* warning: this prints decoded password which maybe not what you want to do @?@ @?@ */
+ /* warning: this prints decoded password which maybe not be what you want to do @?@ @?@ */
debugs(16, 9, "CacheManager::ParseHeaders: got user: '" <<
params.userName << "' passwd: '" << params.password << "'");
+#endif
}
/**
errorStateFree(errState);
+#if HAVE_AUTH_MODULE_BASIC
/*
* add Authenticate header using action name as a realm because
* password depends on the action
*/
rep->header.putAuth("Basic", actionName);
+#endif
/* store the reply */
entry->replaceHttpReply(rep);
int
FtpStateData::checkAuth(const HttpHeader * req_hdr)
{
- const char *auth;
-
/* default username */
xstrncpy(user, "anonymous", MAX_URL);
+#if HAVE_AUTH_MODULE_BASIC
/* Check HTTP Authorization: headers (better than defaults, but less than URL) */
+ const char *auth;
if ( (auth = req_hdr->getAuth(HDR_AUTHORIZATION, "Basic")) ) {
flags.authenticated = 1;
loginParser(auth, FTP_LOGIN_NOT_ESCAPED);
}
/* we fail with authorization-required error later IFF the FTP server requests it */
+#endif
/* Test URL login syntax. Overrides any headers received. */
loginParser(request->login, FTP_LOGIN_ESCAPED);
HttpReply *newrep = err->BuildHttpReply();
errorStateFree(err);
+
+#if HAVE_AUTH_MODULE_BASIC
/* add Authenticate header */
newrep->header.putAuth("Basic", ftpRealm());
+#endif
// add it to the store entry for response....
entry->replaceHttpReply(newrep);
ErrorState *err = errorCon(ERR_CACHE_ACCESS_DENIED, HTTP_UNAUTHORIZED, request);
HttpReply *newrep = err->BuildHttpReply();
errorStateFree(err);
+#if HAVE_AUTH_MODULE_BASIC
/* add Authenticate header */
newrep->header.putAuth("Basic", realm);
+#endif
return newrep;
}