Support ldap, gss and sspi authentication methods in the pg_hba.conf editor.
authordpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Tue, 31 Mar 2009 13:18:26 +0000 (13:18 +0000)
committerdpage <dpage@a7884b65-44f6-0310-8a51-81a127f17b15>
Tue, 31 Mar 2009 13:18:26 +0000 (13:18 +0000)
git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7781 a7884b65-44f6-0310-8a51-81a127f17b15

CHANGELOG
pgadmin/dlg/dlgHbaConfig.cpp
pgadmin/include/dlg/dlgHbaConfig.h
pgadmin/include/utils/pgconfig.h
pgadmin/utils/pgconfig.cpp

index 17476fec46b3363c05525073b894b9645fb17f0b..8be6cd989a779cbce153c49a73a61d5ed05706d2 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -36,6 +36,8 @@ Changes
 \r
 Date       Dev Ver     Change details\r
 ---------- --- ------  --------------\r
+2009-03-31 DP  1.10.0  Support ldap, gss and sspi authentication methods in the\r
+                       pg_hba.conf editor.\r
 2009-03-27 DP  1.10.0  Remove the 'use tab key for autocomplete' option as it\r
                        breaks other editor features for little gain.\r
 2009-03-19 DP  1.10.0  Ensure that dependencies between tables and sequences\r
index 8e4e3adec8f25f304b508d8d8ceb20c6fb76eec5..6b889fb85fa09b28c8f6835e05fbb921457f3919 100644 (file)
@@ -52,12 +52,14 @@ END_EVENT_TABLE()
 #define stOption            CTRL_STATIC("stOption")
 
 
-dlgHbaConfig::dlgHbaConfig(pgFrame *parent, pgHbaConfigLine *_line, pgConn *conn) : 
+dlgHbaConfig::dlgHbaConfig(pgFrame *parent, pgHbaConfigLine *_line, pgConn *_conn) : 
 DialogWithHelp((frmMain*)parent)
 {
     wxWindowBase::SetFont(settings->GetSystemFont());
     LoadResource((wxWindow*)parent, wxT("dlgHbaConfig"));
 
+    conn = _conn;
+
     userAdding = databaseAdding = false;
 
     // Icon
@@ -88,6 +90,27 @@ DialogWithHelp((frmMain*)parent)
     cbMethod->Append(wxT("ident"));
     cbMethod->Append(wxT("pam"));
 
+    if (conn)
+    {
+        // LDAP is supported from 8.2
+        if (conn->BackendMinimumVersion(8, 2))
+            cbMethod->Append(wxT("ldap"));
+
+        // GSS/SSPI are supported from 8.3
+        if (conn->BackendMinimumVersion(8, 3))
+        {
+            cbMethod->Append(wxT("gss"));
+            cbMethod->Append(wxT("sspi"));
+        }
+    }
+    else
+    {
+        // Add all version-dependent methods if we don't know what version we have.
+        cbMethod->Append(wxT("ldap"));
+        cbMethod->Append(wxT("gss"));
+        cbMethod->Append(wxT("sspi"));
+    }
+
     if (conn)
     {
         pgSet *set=conn->ExecuteSet(wxT("SELECT datname FROM pg_database"));
@@ -284,7 +307,27 @@ void dlgHbaConfig::OnChange(wxCommandEvent& ev)
     stIPaddress->Enable(needIp);
     txtIPaddress->Enable(needIp);
 
-    bool needOption = (cbMethod->GetCurrentSelection() >= pgHbaConfigLine::PGC_IDENT);
+    bool needOption = false;
+    // IDENT and LDAP always take an option
+    if (cbMethod->GetCurrentSelection() == pgHbaConfigLine::PGC_IDENT ||
+        cbMethod->GetCurrentSelection() == pgHbaConfigLine::PGC_LDAP)
+    {
+        needOption = true;
+    }
+    else if (cbMethod->GetCurrentSelection() == pgHbaConfigLine::PGC_GSS ||
+             cbMethod->GetCurrentSelection() == pgHbaConfigLine::PGC_SSPI)
+    {
+        // GSS/SSPI take options from 8.4 onwards. If we don't know the version
+        // then allow the option to be specified.
+        if (conn)
+        {
+            if (conn->BackendMinimumVersion(8, 4))
+                needOption = true;
+        }
+        else
+            needOption = true;
+    }
+
     stOption->Enable(needOption);
     txtOption->Enable(needOption);
 
@@ -307,7 +350,10 @@ void dlgHbaConfig::OnOK(wxCommandEvent& ev)
     line->user = user;
     line->ipaddress = txtIPaddress->GetValue();
     line->method = (pgHbaConfigLine::pgHbaMethod)cbMethod->GetCurrentSelection();
-    line->option = txtOption->GetValue();
+    if (txtOption->IsEnabled())
+        line->option = txtOption->GetValue();
+    else
+        line->option = wxEmptyString;
     line->changed = true;
 
     EndModal(wxID_OK);
index 02bfc5a91feb7aa3c3f2b8fe75498e6cbfa74afe..dd98edbb2616f152b82e64ec30d47b6365e3b299 100644 (file)
@@ -19,7 +19,7 @@
 class dlgHbaConfig : public DialogWithHelp
 {
 public:
-    dlgHbaConfig(pgFrame *parent, pgHbaConfigLine *line, pgConn *conn);
+    dlgHbaConfig(pgFrame *parent, pgHbaConfigLine *line, pgConn *_conn);
     ~dlgHbaConfig();
     wxString GetHelpPage() const;
 
@@ -39,6 +39,8 @@ private:
 
     bool databaseAdding, userAdding;
 
+    pgConn *conn;
+
     DECLARE_EVENT_TABLE()
 };
 
index ea757b5f88e2d676d9a2d31996f76d7117eee493..9b075632bb21e55af632c41cba2c9d69a9f67314 100644 (file)
@@ -76,6 +76,9 @@ public:
         PGC_KRB5,
         PGC_IDENT,
         PGC_PAM,
+        PGC_LDAP,
+        PGC_GSS,
+        PGC_SSPI,
         PGC_INVALIDMETHOD
     };
 
index 1ded7066e9b77626378d3c56fc168795e6892c16..9ca987f77c88a7d05d445c9c565d504aaf0ff58d 100644 (file)
@@ -354,6 +354,9 @@ const wxChar *pgHbaMethodStrings[] =
     wxT("krb5"),
     wxT("ident"),
     wxT("pam"),
+    wxT("ldap"),
+    wxT("gss"),
+    wxT("sspi"),
     0
 };