Moves the "program" parse and dump code into Auth::Config.
Also, changes API to Auth::Config::dump() to not dump any config settings
for schemes which are not configured with a "program". Including scheme
specific settings.
Also, fixes missing Digest "utf8" parameter in config dump.
#include "format/Format.h"
#include "globals.h"
#include "Store.h"
+#include "wordlist.h"
Auth::ConfigVector Auth::TheConfig;
void
Auth::Config::parse(Auth::Config * scheme, int n_configured, char *param_str)
{
- if (strcmp(param_str, "realm") == 0) {
+ if (strcmp(param_str, "program") == 0) {
+ if (authenticateProgram)
+ wordlistDestroy(&authenticateProgram);
+
+ parse_wordlist(&authenticateProgram);
+
+ requirePathnameExists("Authentication helper program", authenticateProgram->key);
+
+ } else if (strcmp(param_str, "realm") == 0) {
realm.clear();
char *token = ConfigParser::NextQuotedOrToEol();
}
}
-void
-Auth::Config::dump(StoreEntry *entry, const char *name, Auth::Config *scheme)
+bool
+Auth::Config::dump(StoreEntry *entry, const char *name, Auth::Config *scheme) const
{
+ if (!authenticateProgram)
+ return false; // not configured
+
+ wordlist *list = authenticateProgram;
+ storeAppendPrintf(entry, "%s %s", name, scheme->type());
+ while (list != NULL) {
+ storeAppendPrintf(entry, " %s", list->key);
+ list = list->next;
+ }
+ storeAppendPrintf(entry, "\n");
+
storeAppendPrintf(entry, "%s %s realm " SQUIDSBUFPH "\n", name, scheme->type(), SQUIDSBUFPRINT(realm));
storeAppendPrintf(entry, "%s %s children %d startup=%d idle=%d concurrency=%d\n",
if (keyExtrasLine.size() > 0)
storeAppendPrintf(entry, "%s %s key_extras \"%s\"\n", name, scheme->type(), keyExtrasLine.termedBuf());
+
+ return true;
}
void
/**
* Responsible for writing to the StoreEntry the configuration parameters that a user
* would put in a config file to recreate the running configuration.
+ * Returns whether the scheme is configured.
*/
- virtual void dump(StoreEntry *, const char *, Config *);
+ virtual bool dump(StoreEntry *, const char *, Config *) const;
/** add headers as needed when challenging for auth */
virtual void fixHeader(UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *) = 0;
wordlistDestroy(&authenticateProgram);
}
-void
-Auth::Basic::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme)
+bool
+Auth::Basic::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const
{
- wordlist *list = authenticateProgram;
- storeAppendPrintf(entry, "%s %s", name, "basic");
-
- while (list != NULL) {
- storeAppendPrintf(entry, " %s", list->key);
- list = list->next;
- }
-
- storeAppendPrintf(entry, "\n");
+ if (!Auth::Config::dump(entry, name, scheme))
+ return false; // not configured
storeAppendPrintf(entry, "%s basic credentialsttl %d seconds\n", name, (int) credentialsTTL);
storeAppendPrintf(entry, "%s basic casesensitive %s\n", name, casesensitive ? "on" : "off");
- Auth::Config::dump(entry, name, scheme);
+ storeAppendPrintf(entry, "%s basic utf8 %s\n", name, utf8 ? "on" : "off");
+ return true;
}
Auth::Basic::Config::Config() :
void
Auth::Basic::Config::parse(Auth::Config * scheme, int n_configured, char *param_str)
{
- if (strcmp(param_str, "program") == 0) {
- if (authenticateProgram)
- wordlistDestroy(&authenticateProgram);
-
- parse_wordlist(&authenticateProgram);
-
- requirePathnameExists("auth_param basic program", authenticateProgram->key);
- } else if (strcmp(param_str, "credentialsttl") == 0) {
+ if (strcmp(param_str, "credentialsttl") == 0) {
parse_time_t(&credentialsTTL);
} else if (strcmp(param_str, "casesensitive") == 0) {
parse_onoff(&casesensitive);
virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm);
virtual void done();
virtual void rotateHelpers();
- virtual void dump(StoreEntry *, const char *, Auth::Config *);
+ virtual bool dump(StoreEntry *, const char *, Auth::Config *) const;
virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *);
virtual void init(Auth::Config *);
virtual void parse(Auth::Config *, int, char *);
/* NP: dynamic helper restart will ensure they start up again as needed. */
}
-void
-Auth::Digest::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme)
+bool
+Auth::Digest::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const
{
- wordlist *list = authenticateProgram;
- debugs(29, 9, "Dumping configuration");
- storeAppendPrintf(entry, "%s %s", name, "digest");
-
- while (list != NULL) {
- storeAppendPrintf(entry, " %s", list->key);
- list = list->next;
- }
+ if (!Auth::Config::dump(entry, name, scheme))
+ return false;
- storeAppendPrintf(entry, "\n%s %s nonce_max_count %d\n%s %s nonce_max_duration %d seconds\n%s %s nonce_garbage_interval %d seconds\n",
+ storeAppendPrintf(entry, "%s %s nonce_max_count %d\n%s %s nonce_max_duration %d seconds\n%s %s nonce_garbage_interval %d seconds\n",
name, "digest", noncemaxuses,
name, "digest", (int) noncemaxduration,
name, "digest", (int) nonceGCInterval);
- Auth::Config::dump(entry, name, scheme);
+ storeAppendPrintf(entry, "%s digest utf8 %s\n", name, utf8 ? "on" : "off");
+ return true;
}
bool
virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm);
virtual void done();
virtual void rotateHelpers();
- virtual void dump(StoreEntry *, const char *, Auth::Config *);
+ virtual bool dump(StoreEntry *, const char *, Auth::Config *) const;
virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *);
virtual void init(Auth::Config *);
virtual void parse(Auth::Config *, int, char *);
debugs(29, DBG_IMPORTANT, "Reconfigure: Negotiate authentication configuration cleared.");
}
-void
-Auth::Negotiate::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme)
+bool
+Auth::Negotiate::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const
{
- wordlist *list = authenticateProgram;
- storeAppendPrintf(entry, "%s %s", name, "negotiate");
-
- while (list != NULL) {
- storeAppendPrintf(entry, " %s", list->key);
- list = list->next;
- }
+ if (!Auth::Config::dump(entry, name, scheme))
+ return false;
- storeAppendPrintf(entry, "\n%s %s keep_alive %s\n", name, "negotiate", keep_alive ? "on" : "off");
- Auth::Config::dump(entry, name, scheme);
+ storeAppendPrintf(entry, "%s negotiate keep_alive %s\n", name, keep_alive ? "on" : "off");
+ return true;
}
Auth::Negotiate::Config::Config() : keep_alive(1)
virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm);
virtual void done();
virtual void rotateHelpers();
- virtual void dump(StoreEntry *, const char *, Auth::Config *);
+ virtual bool dump(StoreEntry *, const char *, Auth::Config *) const;
virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *);
virtual void init(Auth::Config *);
virtual void parse(Auth::Config *, int, char *);
debugs(29, DBG_IMPORTANT, "Reconfigure: NTLM authentication configuration cleared.");
}
-void
-Auth::Ntlm::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme)
+bool
+Auth::Ntlm::Config::dump(StoreEntry * entry, const char *name, Auth::Config * scheme) const
{
- wordlist *list = authenticateProgram;
- storeAppendPrintf(entry, "%s %s", name, "ntlm");
-
- while (list != NULL) {
- storeAppendPrintf(entry, " %s", list->key);
- list = list->next;
- }
+ if (!Auth::Config::dump(entry, name, scheme))
+ return false;
- storeAppendPrintf(entry, "\n%s %s keep_alive %s\n", name, "ntlm", keep_alive ? "on" : "off");
- Auth::Config::dump(entry, name, scheme);
+ storeAppendPrintf(entry, "%s ntlm keep_alive %s\n", name, keep_alive ? "on" : "off");
+ return true;
}
Auth::Ntlm::Config::Config() : keep_alive(1)
virtual Auth::UserRequest::Pointer decode(char const *proxy_auth, const char *requestRealm);
virtual void done();
virtual void rotateHelpers();
- virtual void dump(StoreEntry *, const char *, Auth::Config *);
+ virtual bool dump(StoreEntry *, const char *, Auth::Config *) const;
virtual void fixHeader(Auth::UserRequest::Pointer, HttpReply *, http_hdr_type, HttpRequest *);
virtual void init(Auth::Config *);
virtual void parse(Auth::Config *, int, char *);