[Rt-devel] [PATCH] allow "HTTP Basic Auth" for rt commandline tool

Kees Cook kees at osdl.org
Fri Sep 23 20:35:20 EDT 2005


Hello!

This patch lets RT sites that use WebExternalAuth via HTTP Basic Auth use 
the commandline tool.  The attached patch was generated against rt-3.5.5.

(Please CC me, I'm not on the list...)

-- 
Kees Cook
Open Source Development Lab
kees at osdl.org
-------------- next part --------------
diff -uNr rt-3.5.5/bin/rt.in rt-3.5.5-kees/bin/rt.in
--- rt-3.5.5/bin/rt.in	2005-09-02 09:43:09.000000000 -0700
+++ rt-3.5.5-kees/bin/rt.in	2005-09-23 17:32:13.000000000 -0700
@@ -74,6 +74,7 @@
         server  => 'http://localhost/rt/',
         query   => undef,
         orderby => undef,
+        realm   => undef,
     ),
     config_from_file($ENV{RTCONFIG} || ".rtrc"),
     config_from_env()
@@ -776,10 +777,15 @@
     }
 
     # Should we send authentication information to start a new session?
-    if (!defined $session->cookie) {
+    if (!defined $session->cookie && !defined $config{realm}) {
         push @$data, ( user => $config{user} );
         push @$data, ( pass => $config{passwd} || read_passwd() );
     }
+    if (defined $config{realm}) {
+        my $u = new URI($config{server});
+        $ua->credentials( $u->host.":".$u->port, $config{realm},
+                          $config{user}, $config{passwd} );
+    }
 
     # Now, we construct the request.
     if (@$data) {
@@ -1130,7 +1136,7 @@
 sub config_from_env {
     my %env;
 
-    foreach my $k ("DEBUG", "USER", "PASSWD", "SERVER", "QUERY", "ORDERBY") {
+    foreach my $k ("DEBUG", "USER", "PASSWD", "SERVER", "QUERY", "ORDERBY", "REALM") {
         if (exists $ENV{"RT$k"}) {
             $env{lc $k} = $ENV{"RT$k"};
         }
@@ -1182,7 +1188,7 @@
             chomp;
             next if (/^#/ || /^\s*$/);
 
-            if (/^(user|passwd|server|query|orderby)\s+(.*)\s?$/) {
+            if (/^(user|passwd|server|query|orderby|realm)\s+(.*)\s?$/) {
                 $cfg{$1} = $2;
             }
             else {
@@ -1426,6 +1432,7 @@
         - RTUSER
         - RTPASSWD
         - RTSERVER
+        - RTREALM       HTTP Authentication Realm.
         - RTDEBUG       Numeric debug level. (Set to 3 for full logs.)
         - RTCONFIG      Specifies a name other than ".rtrc" for the
                         configuration file.


More information about the Rt-devel mailing list