[Rt-commit] [svn] r829 - in RTx-Atom: . html/Atom/0.3 html/Atom/0.3/Elements html/Atom/0.3/NoAuth lib/RTx

autrijus at pallas.eruditorum.org autrijus at pallas.eruditorum.org
Tue May 4 13:43:58 EDT 2004


Author: autrijus
Date: Tue May  4 13:43:58 2004
New Revision: 829

Added:
   RTx-Atom/html/Atom/0.3/NoAuth/spec.html
   RTx-Atom/html/Atom/0.3/NoAuth/valid-atom.png
Modified:
   RTx-Atom/   (props changed)
   RTx-Atom/html/Atom/0.3/Elements/Error
   RTx-Atom/html/Atom/0.3/NoAuth/autohandler
   RTx-Atom/html/Atom/0.3/dhandler
   RTx-Atom/html/Atom/0.3/index
   RTx-Atom/lib/RTx/Atom.pm
Log:
 ----------------------------------------------------------------------
 r4459 at not:  autrijus | 2004-05-04T14:58:27.230827Z
 
 * Remove redundant wording.
 ----------------------------------------------------------------------
 r4461 at not:  autrijus | 2004-05-04T16:13:38.671227Z
 
 * Put $r->status back to /Elements/Error.
 * /NoAuth/spec.html now returns the current RTx::Atom spec.
 * Handles current-user switching.
 
 ----------------------------------------------------------------------
 r4462 at not:  autrijus | 2004-05-04T16:29:30.935923Z
 
 * Add link and icon to RT-Atom spec in the main index.
 ----------------------------------------------------------------------
 r4464 at not:  autrijus | 2004-05-04T17:43:34.617320Z
 
 * the verb "Put" is now "Set".
 ----------------------------------------------------------------------


Modified: RTx-Atom/html/Atom/0.3/Elements/Error
==============================================================================
--- RTx-Atom/html/Atom/0.3/Elements/Error	(original)
+++ RTx-Atom/html/Atom/0.3/Elements/Error	Tue May  4 13:43:58 2004
@@ -1,6 +1,7 @@
 <%INIT>
 $r->content_type('text/html');
 $r->header_out($ARGS{$_}) for sort keys %ARGS;
+$r->status($Status);
 $m->abort($Status) unless $ENV{FCGI_ROLE};
 </%INIT>
 <%ARGS>

Modified: RTx-Atom/html/Atom/0.3/NoAuth/autohandler
==============================================================================
--- RTx-Atom/html/Atom/0.3/NoAuth/autohandler	(original)
+++ RTx-Atom/html/Atom/0.3/NoAuth/autohandler	Tue May  4 13:43:58 2004
@@ -2,7 +2,8 @@
 my $path = $m->base_comp->path;
 $r->content_type('text/css') if $path =~ /\.css$/i;
 $r->content_type('text/xml') if $path =~ /\.xsl$/i;
-$r->content_type('image/png') if $path =~ /\.png$/i;
+$r->content_type('text/html') if $path =~ /\.html$/i;
+$r->content_type('text/png') if $path =~ /\.png$/i;
 $m->call_next;
 </%INIT>
 <%FLAGS>

Added: RTx-Atom/html/Atom/0.3/NoAuth/spec.html
==============================================================================
--- (empty file)
+++ RTx-Atom/html/Atom/0.3/NoAuth/spec.html	Tue May  4 13:43:58 2004
@@ -0,0 +1,17 @@
+<%INIT>
+my ($fh, $filename) = File::Temp::tempfile();
+
+require lib;
+lib->import($m->base_comp->source_dir . '/../../../../lib');
+require RTx::Atom;
+require Pod::Html;
+
+Pod::Html::pod2html(
+    "--infile=$INC{'RTx/Atom.pm'}",
+    "--outfile=$filename",
+    "--cachedir=" . File::Spec->tmpdir,
+);
+
+seek $fh, 0, 0;
+$r->print(<$fh>);
+</%INIT>

Added: RTx-Atom/html/Atom/0.3/NoAuth/valid-atom.png
==============================================================================
Binary files (empty file) and RTx-Atom/html/Atom/0.3/NoAuth/valid-atom.png	Tue May  4 13:43:58 2004 differ

Modified: RTx-Atom/html/Atom/0.3/dhandler
==============================================================================
--- RTx-Atom/html/Atom/0.3/dhandler	(original)
+++ RTx-Atom/html/Atom/0.3/dhandler	Tue May  4 13:43:58 2004
@@ -8,6 +8,7 @@
     unless @RT::AtomAuthenticationMethods;
 
 my $realm = $RT::rtname;
+
 $realm =~ s/[^\w.]//g;
 my $nonce = Digest::MD5::md5_hex($realm . rand());
 my %methods = map {($_ => 1)} @RT::AtomAuthenticationMethods;
@@ -30,8 +31,6 @@
 ) if $methods{Basic} and !$atom_client;
 
 my $CurrentUser;
-$CurrentUser = RT::CurrentUser->new;
-$CurrentUser->Load('root');
 
 my $headerParts = sub {
     my $header = $r->header_in($_[0]) || $ENV{$_[0]};
@@ -130,6 +129,18 @@
     $nonce_cache->set( $auth_nonce, 1 );
 }
 
+# Now for the dreaded "su anotheruser" feature...
+my $su = $r->header_in('X-RT-CurrentUser');
+if ($CurrentUser and $su and ($su ne $CurrentUser->Id) and ($su ne $CurrentUser->Name)) {
+    # You have to be SuperUser to do this.
+    $CurrentUser->UserObj->HasRight(
+	Right => 'SuperUser',
+        Object => $RT::System,
+    ) or return $m->comp('Elements/Error', Status => 401);
+
+    $CurrentUser->Load($su);
+}
+
 if (!$CurrentUser or !$CurrentUser->Id) {
     return $m->comp('Elements/Error', Status => 401);
 }
@@ -137,6 +148,8 @@
 $session{CurrentUser} = $CurrentUser;
 my $lang = $CurrentUser->LanguageHandle->language_tag;
 $lang = "en, $lang" unless $lang =~ /^en\b/;
+
+$header_out->('X-RT-CurrentUser', $CurrentUser->Id);
 $header_out->('Content-Language', $lang);
 
 my %Methods = (

Modified: RTx-Atom/html/Atom/0.3/index
==============================================================================
--- RTx-Atom/html/Atom/0.3/index	(original)
+++ RTx-Atom/html/Atom/0.3/index	Tue May  4 13:43:58 2004
@@ -21,6 +21,7 @@
   </entry>
 % }
   <info></info>
+  <html:a href="<% $BaseURI %>/NoAuth/spec.html" title="The RT-Atom Specification"><html:img type="image/png" src="<% $BaseURI %>/NoAuth/valid-atom.png" alt="Valid Atom"></html:img></html:a>
 </feed>
 <%ARGS>
 $Path

Modified: RTx-Atom/lib/RTx/Atom.pm
==============================================================================
--- RTx-Atom/lib/RTx/Atom.pm	(original)
+++ RTx-Atom/lib/RTx/Atom.pm	Tue May  4 13:43:58 2004
@@ -180,7 +180,7 @@
     400: Request failed.  Body is the error message.
     404: There is no object matching the specified URI.
 
-=head2 Put - I<PUT EditURI>
+=head2 Set - I<PUT EditURI>
 
 Modifies an object or property with the serialization in the request body.
 
@@ -201,7 +201,7 @@
 Clients without I<DELETE> support may use I<POST EditURI> instead, with an
 empty entry element as the request body.
 
-=head2 Describe - I<OPTIONS PostURI>, I<OPTIONS EditURI>, I<OPTIONS FeedURI>
+=head2 Describe - I<OPTIONS [ PostURI | EditURI | FeedURI ]>
 
 On a container's PostURI, returns the schema of objects acceptable by this
 container.


More information about the Rt-commit mailing list