cross
New Foswiki release 2.1.6 is available with important security fixes.
Sourceforge foswiki email lists being discontinued. Subscribe to the new Foswiki announce and discuss lists at MailingLists
This question about Using an extension: Answered

ERROR: (405) Bad Request: REST denied

Since we've updated the plugin to the neweset version and we want to generate the cache initially with

`cd <foswiki-root>/bin; ./rest /DBCachePlugin/updateCache`

we get the following error:

ERROR: (405) Bad Request: REST denied.

Any hints how to solve this problem?

Regards

-- JeroNimo - 28 May 2015

Known problem calling rest on the cmdline. Try this patch

diff --git a/lib/Foswiki/UI/Rest.pm b/lib/Foswiki/UI/Rest.pm
index f24e7bf..5c2b777 100644
--- a/lib/Foswiki/UI/Rest.pm
+++ b/lib/Foswiki/UI/Rest.pm
@@ -190,6 +190,7 @@ sub rest {

     # Check the method is allowed
     if ( $record->{http_allow} && defined $req->method() ) {
+      unless ( $session->inContext('command_line') ) {
         my %allowed = map { $_ => 1 } split( /[,\s]+/, $record->{http_allow} );
         unless ( $allowed{ uc( $req->method() ) } ) {
             $res->header( -type => 'text/html', -status => '405' );
@@ -198,12 +199,14 @@ sub rest {
             $res->print($err);
             throw Foswiki::EngineException( 404, $err, $res );
         }
+      }
     }

     # Check someone is logged in
     if ( $record->{authenticate} ) {
         unless ( $session->inContext('authenticated')
-            || $Foswiki::cfg{LoginManager} eq 'none' )
+            || $Foswiki::cfg{LoginManager} eq 'none' 
+            || $session->inContext('command_line') )
         {
             $res->header( -type => 'text/html', -status => '401' );
             $err = "ERROR: (401) $pathInfo requires you to be logged in";
@@ -213,7 +216,11 @@ sub rest {
     }

     # Validate the request
-    if ( $record->{validate} ) {
+    if (   $record->{validate}
+        && $Foswiki::cfg{Validation}{Method} ne 'none'
+        && !$session->inContext('command_line') )
+    {
+
         my $nonce = $req->param('validation_key');
         if (
             !defined($nonce)

While you are at it - and in case you've got $Foswiki::cfg{Register}{AllowLoginName} enabled - have this patch as well so that you are recognized as admin on the commandline.

--- old/lib/Foswiki/Engine/CLI.pm 
+++ foswiki/lib/Foswiki/Engine/CLI.pm 
@@ -77,7 +77,12 @@
         delete $this->{user};
     }
     else {
-        $req->remoteUser( $Foswiki::cfg{AdminUserWikiName} );
+       if ( $Foswiki::cfg{Register}{AllowLoginName} ) { 
+           $req->remoteUser( $Foswiki::cfg{AdminUserLogin} ); 
+       } 
+       else { 
+           $req->remoteUser( $Foswiki::cfg{AdminUserWikiName} ); 
+       } 
     }
 }

Also: remove rest from $Foswiki::cfg{AuthScripts}.

This is fixed in Foswiki-1.2.0.

-- MichaelDaum - 28 May 2015

Thanks Michael, I had the same symptom and applied the patch. Then it worked. Cool smile

-- BramVanOosterhout - 13 Jun 2015
 

QuestionForm edit

Subject Using an extension
Extension DBCachePlugin
Version Foswiki 1.1.9
Status Answered
Related Topics
Topic revision: r3 - 13 Jun 2015, BramVanOosterhout - This page was cached on 14 Jun 2018 - 22:11.

The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy