Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8150967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T15:13:18+00:00 2026-06-06T15:13:18+00:00

CakePHP has a requireSecure function in the SecurityComponent. I’m using this to force SSL

  • 0

CakePHP has a requireSecure function in the SecurityComponent. I’m using this to force SSL when passing sensitive information such as a credit card number.

Questions:

  • Is there a requireNonSecure function?
  • If there’s no requireNonSecure function is it possible to extend/add a function to CakePHP’s core file without modifying the original file?

I want a requireNonSecure function because some of my pages have embedded videos that can only be played on our domain name. When using SSL the video hosting service does not recognize our domain name and cannot play the videos.

This is some of the code in the beforeFilter of a controller:

function beforeFilter() {
    parent::beforeFilter();

    $this->Security->validatePost = false; // disable CSRF protection
    $this->Security->blackHoleCallback = 'forceSSL';
    $this->Security->requireSecure('pay', 'index');

    $this->Auth->allow('index');
}

This is the callback in app_controller.php

function forceSSL() {
    $redirect = '';
    if (!empty($this->params['url']['redirect'])) {
        $redirect = '?redirect=' . $this->params['url']['redirect'];
    }

    $this->redirect('https://' . rtrim(env('SERVER_NAME'), '/') . $this->here . $redirect);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T15:13:19+00:00Added an answer on June 6, 2026 at 3:13 pm

    A solution would be to append a function to beforeFilter like this:

    In a controller:

    function beforeFilter() {
        parent::beforeFilter();
    
        // Require non secure (http) for video action
        $this->requireNonSecure('video');
    
        // ... other code here
    
    }
    

    In app_controller.php:

    function requireNonSecure() {
        $requireNonSecure = array_map('strtolower', func_get_args());
    
        if (in_array(strtolower($this->action), $requireNonSecure) || $requireNonSecure == array('*')) {
            if ($this->RequestHandler->isSSL()) {
                $this->redirect('http://' . rtrim(env('SERVER_NAME'), '/') . $this->here);
                return;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using cakephp and trying to check if a table has data entered in
I'm trying to create an XML sitemap using CakePHP, from a table which has
I'm using CakePHP to build a site which has a crawler that mines data
I have a website made with CakePHP 1.3.7. This website has it's own login
I have a shopping cart system in Cakephp, this table has all your usual
Can somebody perhaps explain here why on earth CakePHP has a convention of using
I have a Cakephp project the controller has several different methods. function Index() function
I have a site (built on LAMP (cakephp) and has ssl certificate installed) which
Hey, im having this issue with cakephp, bascially i have a Has And Belongs
CakePHP-2.0 has this=> // Even in your cakephp 2.1.x we have this format <?php

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.