php使用phpCAS接入CAS SSO

源码:https://github.com/Jasig/phpCAS

文档:https://wiki.jasig.org/display/CASC/phpCAS+examples


安 装

ubuntu下使用pear安装

sudo pear install  http://downloads.jasig.org/cas-clients/php/current.tgz


配置

//  CAS Server 主机
$cas_host = ‘cas-server‘;

// CAS Server 路径
$cas_context = ‘/cas‘;

// CAS server.端口
$cas_port = 443;

// <span>CAS Server </span>证书
$cas_server_ca_cert_path = ‘./ssoserver.cer‘;


使用

//验证访问用户是否合法
require_once ‘include/cas_config.php‘;


require_once  ‘phpcas/CAS.php‘;

// Enable debugging
phpCAS::setDebug();


// Initialize phpCAS
phpCAS::client(CAS_VERSION_2_0, $cas_host, $cas_port, $cas_context);


// For production use set the CA certificate that is the issuer of the cert
// on the CAS server and uncomment the line below
// phpCAS::setCasServerCACert($cas_server_ca_cert_path);


// For quick testing you can disable SSL validation of the CAS server.
// THIS SETTING IS NOT RECOMMENDED FOR PRODUCTION.
// VALIDATING THE CAS SERVER IS CRUCIAL TO THE SECURITY OF THE CAS PROTOCOL!
phpCAS::setNoCasServerValidation();


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

// 取得登陆用户id
$cas_user_id = phpCAS::getAttribute(‘id‘);


//phpCAS::logout();



原 理

推荐资料:http://blog.chinaunix.net/uid-22816738-id-3525939.html


php使用phpCAS接入CAS SSO,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。