cakePHP集成CAS

环境要求:

    * CURL 7.5+
    * PHP 4.3.1+, PEAR DB
    * Apache 2.0.44+
    * CakePHP

系统要求:
    CURL

       CURL libs must be present on your system, and they must have been compiled with SSL support.
    PHP >= 4.2.2

       phpCAS users must have PHP compiled with the following options:

    * --with-curl: CURL support, needed to access proxies.
    * --with-openssl: SSL support, needed for fopen('https://...'), to validate CAS tickets;
    * --with-dom: DOM support, to read the XML responses of the CAS server (PHP4);
    * --with-zlib: Zlib support, needed by DOM.

      When used within the Horde FrameWork:

    * --with-gettext: gettext support.

      When used within Horde IMP:

    * --with-imap: IMAP and POP support, needed when using IMP;
    * --with-kerberos: Kerberos support, needed by IMAP.

      When storing Horde user preferences to MySQL databases:

    * --with-mysql: MySQL support.

      Notes:

    * PHP >= 4.3.0 is needed to get full logging information (thanks to debug_backtrace()).
    * On some systems (Fedora Core 2 for instance), package php_domxml is required.

      注意:php必须安装这些扩展功能


环境搭建:

      CAS-Client的PHP版本下载:http://www.ja-sig.org/downloads/cas-clients/php/1.1.1/CAS-1.1.1.tgz

      cakePHP下载:http://github.com/cakephp/cakephp/downloads

      cakePHP配置apache查看其它文档

      php安装


cakePHP集成CAS:


      第一步:解压cas 1.X.X,把目录下CAS目录和CAS.php文件复制到cakePHP的app目录!


      第二步:cakePHP的app/views/elements目录下添加文件cas_bar.ctp

                   内容如下:

      <?php

        //
        // phpCAS simple client
        //

        // import phpCAS lib
        include_once('CAS.php');

        phpCAS::setDebug();

        // initialize phpCAS
        phpCAS::client(CAS_VERSION_2_0,'vm.netqin.com',8443,'cas');

        // no SSL validation for the CAS server
        phpCAS::setNoCasServerValidation();

        // force CAS authentication
        phpCAS::forceAuthentication();

        // at this step, the user has been authenticated by the CAS server
        // and the user's login name can be read with phpCAS::getUser().

        // logout if desired
        if (isset($_REQUEST['logout'])) {
            phpCAS::logout();
        }

        // for this test, simply print that the authentication was successfull
     ?>

  

   第三步:

        php页面引用:<?php echo $this->element('cas_bar'); ?>

        备注:可以放在cakePHP自己配置的默认页(app/views/default.ctp)


   第四步:访问嵌入car_bar的页面就会自动跳转到登陆页面。
               获得登陆用户:<?php echo phpCAS::getUser(); ?>

               phpCAS的版本:<?php echo phpCAS::getVersion(); ?>

               登出:<p><a href="?logout=">Logout</a></p>
    

相关资料:

https://wiki.jasig.org/display/CASC/phpCAS+installation+guide

你可能感兴趣的:(apache,mysql,PHP,Access,cakephp)