Pentaho REST API: Issue when using Pentaho Cookie-Based Authentication












2















Been struggling with this for a while, so any help is really appreciated...



I have Pentaho reports loaded into Pentaho Server. These reports are called via an Iframe.



What I'm trying to do is have the user authenticate one time only, so he can run other reports without having to reauthenticate. For that, I use Pentaho Cookie-Based Authentication as documented here: https://help.pentaho.com/Documentation/8.0/Developer_Center/REST_API



My issues are:
1) I wrote a small php script that sends a POST request to /pentaho/j_spring_security_check. The scripts does not return any error, but does not redirect me to home page as expected.



<?php
$data = array("j_username"=>"admin", "j_password"=>"password",
"locale"=>"en_US");
$string = http_build_query($data);
echo $string;
$ch =
curl_init("http://localhost:8080/pentaho/j_spring_security_check");
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
echo $ch;
$return = curl_exec($ch);
echo $return;
if (curl_errno($ch)) {
print curl_error($ch);
}
curl_close($ch);
?>


2) I tried typing directly in the browser "http://localhost:8080/pentaho/j_spring_security_check?j_username=admin&j_password=admin", I get the "login_error=1" result, while both logins and passwords are correct (the expected behaviour is to be redirected to the home page).



It's the first time I'm using REST API, so I might be doing things wrong.



Many thanks










share|improve this question



























    2















    Been struggling with this for a while, so any help is really appreciated...



    I have Pentaho reports loaded into Pentaho Server. These reports are called via an Iframe.



    What I'm trying to do is have the user authenticate one time only, so he can run other reports without having to reauthenticate. For that, I use Pentaho Cookie-Based Authentication as documented here: https://help.pentaho.com/Documentation/8.0/Developer_Center/REST_API



    My issues are:
    1) I wrote a small php script that sends a POST request to /pentaho/j_spring_security_check. The scripts does not return any error, but does not redirect me to home page as expected.



    <?php
    $data = array("j_username"=>"admin", "j_password"=>"password",
    "locale"=>"en_US");
    $string = http_build_query($data);
    echo $string;
    $ch =
    curl_init("http://localhost:8080/pentaho/j_spring_security_check");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    echo $ch;
    $return = curl_exec($ch);
    echo $return;
    if (curl_errno($ch)) {
    print curl_error($ch);
    }
    curl_close($ch);
    ?>


    2) I tried typing directly in the browser "http://localhost:8080/pentaho/j_spring_security_check?j_username=admin&j_password=admin", I get the "login_error=1" result, while both logins and passwords are correct (the expected behaviour is to be redirected to the home page).



    It's the first time I'm using REST API, so I might be doing things wrong.



    Many thanks










    share|improve this question

























      2












      2








      2


      1






      Been struggling with this for a while, so any help is really appreciated...



      I have Pentaho reports loaded into Pentaho Server. These reports are called via an Iframe.



      What I'm trying to do is have the user authenticate one time only, so he can run other reports without having to reauthenticate. For that, I use Pentaho Cookie-Based Authentication as documented here: https://help.pentaho.com/Documentation/8.0/Developer_Center/REST_API



      My issues are:
      1) I wrote a small php script that sends a POST request to /pentaho/j_spring_security_check. The scripts does not return any error, but does not redirect me to home page as expected.



      <?php
      $data = array("j_username"=>"admin", "j_password"=>"password",
      "locale"=>"en_US");
      $string = http_build_query($data);
      echo $string;
      $ch =
      curl_init("http://localhost:8080/pentaho/j_spring_security_check");
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      echo $ch;
      $return = curl_exec($ch);
      echo $return;
      if (curl_errno($ch)) {
      print curl_error($ch);
      }
      curl_close($ch);
      ?>


      2) I tried typing directly in the browser "http://localhost:8080/pentaho/j_spring_security_check?j_username=admin&j_password=admin", I get the "login_error=1" result, while both logins and passwords are correct (the expected behaviour is to be redirected to the home page).



      It's the first time I'm using REST API, so I might be doing things wrong.



      Many thanks










      share|improve this question














      Been struggling with this for a while, so any help is really appreciated...



      I have Pentaho reports loaded into Pentaho Server. These reports are called via an Iframe.



      What I'm trying to do is have the user authenticate one time only, so he can run other reports without having to reauthenticate. For that, I use Pentaho Cookie-Based Authentication as documented here: https://help.pentaho.com/Documentation/8.0/Developer_Center/REST_API



      My issues are:
      1) I wrote a small php script that sends a POST request to /pentaho/j_spring_security_check. The scripts does not return any error, but does not redirect me to home page as expected.



      <?php
      $data = array("j_username"=>"admin", "j_password"=>"password",
      "locale"=>"en_US");
      $string = http_build_query($data);
      echo $string;
      $ch =
      curl_init("http://localhost:8080/pentaho/j_spring_security_check");
      curl_setopt($ch, CURLOPT_POST, true);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $string);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      echo $ch;
      $return = curl_exec($ch);
      echo $return;
      if (curl_errno($ch)) {
      print curl_error($ch);
      }
      curl_close($ch);
      ?>


      2) I tried typing directly in the browser "http://localhost:8080/pentaho/j_spring_security_check?j_username=admin&j_password=admin", I get the "login_error=1" result, while both logins and passwords are correct (the expected behaviour is to be redirected to the home page).



      It's the first time I'm using REST API, so I might be doing things wrong.



      Many thanks







      spring-security pentaho restful-authentication






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 '18 at 10:21









      PetethetPetethet

      212




      212
























          1 Answer
          1






          active

          oldest

          votes


















          1














          answered here: https://community.hitachivantara.com/thread/14811-pentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication



          I was missing the step where I would reuse that cookie.



          Also, using "curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true)" helped me understand mistakes in my script and solve it.



          Correct script is:



          <?php
          $data = array("user"=>"admin", "password"=>"admin");
          // $string = http_build_query($data);
          // echo $string;

          $cookie_jar = tempnam('/Users/pierre/Vrac','cookie');
          if (!file_exists(realpath($cookie_jar))) touch($cookie_jar);

          $ch = curl_init("http://localhost:8080/pentaho/j_spring_security_check?
          j_username=admin&j_password=admin&locale=en_US");
          curl_setopt($ch, CURLOPT_POST, true);
          curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
          curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
          curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
          curl_setopt($ch, CURLOPT_HEADER, true);

          //echo $ch;
          $return = curl_exec($ch);

          echo "execution report";
          curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
          curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
          curl_setopt($ch, CURLOPT_URL,'http://localhost:8080/pentaho/api/repos/:public:IframeDossier:IframeTest.prpt/viewer?label=fin');
          $page = curl_exec($ch);
          echo $page;


          curl_close($ch);

          ?>





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390859%2fpentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            1














            answered here: https://community.hitachivantara.com/thread/14811-pentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication



            I was missing the step where I would reuse that cookie.



            Also, using "curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true)" helped me understand mistakes in my script and solve it.



            Correct script is:



            <?php
            $data = array("user"=>"admin", "password"=>"admin");
            // $string = http_build_query($data);
            // echo $string;

            $cookie_jar = tempnam('/Users/pierre/Vrac','cookie');
            if (!file_exists(realpath($cookie_jar))) touch($cookie_jar);

            $ch = curl_init("http://localhost:8080/pentaho/j_spring_security_check?
            j_username=admin&j_password=admin&locale=en_US");
            curl_setopt($ch, CURLOPT_POST, true);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
            curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
            curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
            curl_setopt($ch, CURLOPT_HEADER, true);

            //echo $ch;
            $return = curl_exec($ch);

            echo "execution report";
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
            curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
            curl_setopt($ch, CURLOPT_URL,'http://localhost:8080/pentaho/api/repos/:public:IframeDossier:IframeTest.prpt/viewer?label=fin');
            $page = curl_exec($ch);
            echo $page;


            curl_close($ch);

            ?>





            share|improve this answer




























              1














              answered here: https://community.hitachivantara.com/thread/14811-pentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication



              I was missing the step where I would reuse that cookie.



              Also, using "curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true)" helped me understand mistakes in my script and solve it.



              Correct script is:



              <?php
              $data = array("user"=>"admin", "password"=>"admin");
              // $string = http_build_query($data);
              // echo $string;

              $cookie_jar = tempnam('/Users/pierre/Vrac','cookie');
              if (!file_exists(realpath($cookie_jar))) touch($cookie_jar);

              $ch = curl_init("http://localhost:8080/pentaho/j_spring_security_check?
              j_username=admin&j_password=admin&locale=en_US");
              curl_setopt($ch, CURLOPT_POST, true);
              curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
              curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
              curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
              curl_setopt($ch, CURLOPT_HEADER, true);

              //echo $ch;
              $return = curl_exec($ch);

              echo "execution report";
              curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
              curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
              curl_setopt($ch, CURLOPT_URL,'http://localhost:8080/pentaho/api/repos/:public:IframeDossier:IframeTest.prpt/viewer?label=fin');
              $page = curl_exec($ch);
              echo $page;


              curl_close($ch);

              ?>





              share|improve this answer


























                1












                1








                1







                answered here: https://community.hitachivantara.com/thread/14811-pentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication



                I was missing the step where I would reuse that cookie.



                Also, using "curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true)" helped me understand mistakes in my script and solve it.



                Correct script is:



                <?php
                $data = array("user"=>"admin", "password"=>"admin");
                // $string = http_build_query($data);
                // echo $string;

                $cookie_jar = tempnam('/Users/pierre/Vrac','cookie');
                if (!file_exists(realpath($cookie_jar))) touch($cookie_jar);

                $ch = curl_init("http://localhost:8080/pentaho/j_spring_security_check?
                j_username=admin&j_password=admin&locale=en_US");
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_HEADER, true);

                //echo $ch;
                $return = curl_exec($ch);

                echo "execution report";
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
                curl_setopt($ch, CURLOPT_URL,'http://localhost:8080/pentaho/api/repos/:public:IframeDossier:IframeTest.prpt/viewer?label=fin');
                $page = curl_exec($ch);
                echo $page;


                curl_close($ch);

                ?>





                share|improve this answer













                answered here: https://community.hitachivantara.com/thread/14811-pentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication



                I was missing the step where I would reuse that cookie.



                Also, using "curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true)" helped me understand mistakes in my script and solve it.



                Correct script is:



                <?php
                $data = array("user"=>"admin", "password"=>"admin");
                // $string = http_build_query($data);
                // echo $string;

                $cookie_jar = tempnam('/Users/pierre/Vrac','cookie');
                if (!file_exists(realpath($cookie_jar))) touch($cookie_jar);

                $ch = curl_init("http://localhost:8080/pentaho/j_spring_security_check?
                j_username=admin&j_password=admin&locale=en_US");
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
                curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_jar);
                curl_setopt ($ch, CURLOPT_RETURNTRANSFER, true);
                curl_setopt($ch, CURLOPT_HEADER, true);

                //echo $ch;
                $return = curl_exec($ch);

                echo "execution report";
                curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
                curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_jar);
                curl_setopt($ch, CURLOPT_URL,'http://localhost:8080/pentaho/api/repos/:public:IframeDossier:IframeTest.prpt/viewer?label=fin');
                $page = curl_exec($ch);
                echo $page;


                curl_close($ch);

                ?>






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 '18 at 13:10









                PetethetPetethet

                212




                212
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53390859%2fpentaho-rest-api-issue-when-using-pentaho-cookie-based-authentication%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    How to send String Array data to Server using php in android

                    Title Spacing in Bjornstrup Chapter, Removing Chapter Number From Contents

                    Is anime1.com a legal site for watching anime?