`

cakePHP集成CAS

    博客分类:
  • php
阅读更多
环境要求:

    * 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
分享到:
评论

相关推荐

    PHP的框架之CakePHP-CakePHP教程

    打包下载,里面有CakePHP的框架源码,下载后可直接使用,版本是1.1的,稳定版;CakePHP的分页组件源码;CakePHP的中文及英文教程,CHM格式;CakePHP的中文打印版教程,WORD格式,下载后可直接打印,方便的;CakePHP...

    cakephp php-framework

    There are two main ways to get a fresh copy of CakePHP. You can either download an archive copy (zip/tar.gz/tar.bz2) from the main website, or check out the code from the git repository. To download ...

    cakephp 框架

    cakephp 框架 cakephp 框架 cakephp 框架 cakephp 框架 cakephp 框架

    PHP的框架之CakePHP-CakePHP教程终极教程

    打包下载,里面有CakePHP的框架源码,下载后可直接使用,版本是1.1的,稳定版;CakePHP的分页组件源码;CakePHP的中文及英文教程,CHM格式;CakePHP的中文打印版教程,WORD格式,下载后可直接打印,方便的;CakePHP...

    CakePHP 3.4 开发手册文档 CakePHP Cookbook Documentation Release 3.4

    CakePHP 3.4 开发手册文档 CakePHP Cookbook Documentation Release 3.4

    Beginning CakePHP:From Novice to Professional

    Lead you from a basic setup of CakePHP to building a couple applications that will highlight CakePHPs functionality and capabilities without delving too deeply into the PHP language, but rather ...

    cakephp分页.docx

    cakephp分页,cakephp框架的分页的方法的文档,是cakephp框架的内容。

    cakephp中acl详解

    cakephp中acl详解

    cakephp 框架书籍 英文版

    cakephp 框架书籍 英文版

    cakephp-1.2 manual

    cakephp-1.2 manual 英文版,离线版。

    cakephp-2.2.4-0

    cakephp-2.2.4-0 稳定版框架

    cakephp-twig-integration:CakePHP 安装与 twig 集成

    cakephp-twig-integration CakePHP 安装与 twig 集成核心版本 2.5.7 #Introduction CakePHP 是一个很好的网站开发框架,但我认为升级这个 MVC 的一个有趣的方法是集成 TWIG 引擎,使视图文件的编写更容易、更快、更...

    cakephp-1.3.21.zip

    cakephp-1.3.21.zip

    CakePHP php框架 v3.7.0 beta1.zip

    在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。 CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该...

    cakephp框架源码

    cakephp框架源码cakephp框架源码cakephp框架源码cakephp框架源码cakephp框架源码cakephp框架源码cakephp框架源码cakephp框架源码cakephp框架源码

    CakePHP php框架 v3.7.8.zip

    在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。 CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该...

    CakePHP php框架 v3.8.5

    在cakephp.org站点的Sites in the wild页面可以看到当前使用CakePHP框架的网站列表。CakePHP 是一个运用了诸如ActiveRecord、Association Data Mapping、Front Controller和MVC等著名设计模式的快速开发框架。该项目...

    cakephp-containable行为behaviour

    2:cakephp中虽然对模型的操作方法中并没有提供像上面提到的连贯方法 但是cake框架提供了一个containable行为类来更好的完善模型关联中遇到的上述问题 "&gt;1:thinkphp中通过框架提供的连贯操作Model &gt;join ‘other ...

    cakephp 中文手册

    cakephp 中文手册cakephp 中文手册cakephp 中文手册cakephp 中文手册

    CakePHP 3.5 开发手册文档 CakePHP Cookbook Documentation Release 3.5/共900页 PDF

    CakePHP 3.5 开发手册文档 CakePHP Cookbook Documentation Release 3.5/共900页 PDF

Global site tag (gtag.js) - Google Analytics