SSO 单点登录,是企业为了解决在相互信任的系统上实现一次登录的解决方案。SSO将一个企业内部所有域中的用户登录和用户帐号管理集中到一起,SSO的好处显而易见:
减少用户在不同系统中登录耗费的时间,减少用户登录出错的可能性;实现安全的同时避免了处理和保存多套系统用户的认证信息;减少了系统管理员增加、删除用户和修改用户权限的时间;增加了安全性:系统管理员有了更好的方法管理用户,包括可以通过直接禁止和删除用户来取消该用户对所有系统资源的访问权限。开源的企业级单点登录解决方案。
CAS Server 为需要独立部署的 Web 应用。
CAS Client 支持非常多的客户端(这里指单点登录系统中的各个 Web 应用),包括 Java, .Net, PHP, Perl, Apache, uPortal, Ruby 等。
1 使用composer安装
composer require apereo/phpcas2.tp5使用phpcas
use phpCAS;use thinkfacadeConfig;class Auth{/** * 公司用户CAS登录 */ public function loginCas() { // Full Hostname of your CAS Server $cas_host = Config::get('cas_host'); // Context of the CAS Server $cas_context = Config::get('cas_context'); // Port of your CAS server. Normally for a https server it's 443 $cas_port = Config::get('cas_port'); // Enable debugging phpCAS::setDebug(); // Initialize phpCAS phpCAS::client(CAS_VERSION_3_0, $cas_host, $cas_port, $cas_context); // 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(); phpCAS::forceAuthentication(); //检查是否登录 if(phpCAS::checkAuthentication()){ //获取登陆的用户名 $username = phpCAS::getUser(); } }}3.注意事项
phpCAS::client(CAS_VERSION_3_0, $cas_host, $cas_port, $cas_context)其中四个参数根据CAS服务端进行配置