1

I'm trying to find the correct way to include CAS into Magento. The way I currently have it set up is by including the required files in the index.php file. This works until I turn FPC caching on in Magento then I run into the problem where the first time I login it works but if the next person logs in they are thrown into a redirect loop.

Clearing the cache fixes it for the first person but then the next person runs into the loop issue. It seems to be Magento is caching the ticket it should be receiving so it works the first time but not after.

I don't even know where to being to bust the cache for this.

EDIT: Figured out how to autoload correctly. Still can't figure out why CAS is being cached. I'm initing CAS in the observer by doing phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context).

Looking at the headers I see that CAS is returning with a ticket set but when Magento goes to validate it isn't providing the correct ticket which cause it to go get another and loop.

Final edit: CAS' class wasn't being instantiated correctly. This is resolved with just the library being included correctly.

1

I found out how to load the library correctly.

In the config.xml file in your module you need to add an event observer to the global tags:

    <events>
        <controller_front_init_before>
            <observers>
                <module_name>
                    <type>singleton</type>
                    <class>Module_Name_Model_Observer</class>
                    <method>controllerFrontInitBefore</method>
                </module_name>
            </observers>
        </controller_front_init_before>
    </events>

Then create an Model/Observer.php file in your module folder:

<?php
class Module_Name_Model_Observer
{
    /**
     * @param Varien_Event_Observer $event
     */
    public function controllerFrontInitBefore(Varien_Event_Observer $event)
    {
        self::init();
    }

    static function init()
    {
        // Add our vendor folder to our include path
        set_include_path(get_include_path() . PATH_SEPARATOR . Mage::getBaseDir('lib') . '/library_name');

        require_once(Mage::getBaseDir('lib') . '/library_name/autoloader.php');

    }

}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.