Jump to:

22975 Posts in 11620 Topics by 2826 members

General Questions

SilverStripe Forums » General Questions » What is if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary();

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 893 Views
  • Ryan M.
    Avatar
    Community Member
    309 Posts

    What is if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary(); Link to this post

    What is this?

    if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary();

    It's in Controller.php, on line 78. I had to comment this out to get my site working again after it quit working for some strange reason and kept throwing an error related to that function.

  • Ryan M.
    Avatar
    Community Member
    309 Posts

    Re: What is if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary(); Link to this post

    For reference, the error it throws is:

    Fatal error: Call to undefined method BasicAuth::protect_site_if_necessary() in /var/www/vhosts/domain.com/subdomains/subsite/httpdocs/sapphire/core/control/Controller.php on line 78

  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: What is if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary(); Link to this post

    Hmm strange you're using 2.4? I can see the protect_site_if_necessary() function in the BasicAuth.php file. You want to check your BasicAuth.php file to check that function is there. It may not have been updated correctly.

  • Ryan M.
    Avatar
    Community Member
    309 Posts
  • Willr
    Avatar
    Forum Moderator
    5462 Posts

    Re: What is if($this->basicAuthEnabled) BasicAuth::protect_site_if_necessary(); Link to this post

    Well even my 2.3 site has this, perhaps if you updated the core before (say it was an earlier version) maybe the BasicAuth file didn't get updated.

    The function which should be in BasicAuth.php looks like...

       /**
        * Call {@link BasicAuth::requireLogin()} if {@link BasicAuth::protect_entire_site()} has been called.
        * This is a helper function used by Controller.
        */
       static function protect_site_if_necessary() {
          if(self::$entire_site_protected) {
             self::requireLogin("SilverStripe test website. Use your CMS login.", "ADMIN");
          }
       }

    You could try (if your missing it) just putting that in the BasicAuth.php file. Also note the 2.3 branch is up to 2.3.7 so your 4 versions behind the latest security updates so if you are worried about it, your site could be compromised.

    893 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.