网站首页 > 技术文章 正文
一、搭建服务端
服务端搭建请参考:https://blog.csdn.net/fireofjava/article/details/79142703
二、导入phpCAS依赖
在thinkCMF项目根目录下的composer.json文件中添加"apereo/phpcas": "^1.3.7"
composer.json文件示例:
{ "name": "thinkcmf/thinkcmf", "description": "ThinkCMF based on ThinkPHP 5.0 , it is a free and open source Content Management Framework(CMF)", "type": "project", "keywords": [ "cmf", "thinkcmf", "framework", "thinkphp", "ORM" ], "homepage": "http://www.thinkcmf.com/", "license": "Apache-2.0", "authors": [ { "name": "thinkcmf", "email": "zxxjjforever@163.com" } ], "require": { "php": ">=5.4.0", "ext-json": "*", "topthink/framework": "~5.0.0", "topthink/think-helper": "^1.0", "topthink/think-captcha": "^1.0", "phpmailer/phpmailer": "^5.2", "mindplay/annotations": "^1.3", "topthink/think-image": "^1.0", "ezyang/htmlpurifier": "^4.9", "topthink/think-queue": "^1.1.4", "electrolinux/phpquery": "^0.9.6", "apereo/phpcas": "^1.3.7" }, "extra": { "think-path": "simplewind/thinkphp" }, "config": { "vendor-dir": "simplewind/vendor" }, "repositories": { "packagist": { "type": "composer", "url": "https://packagist.phpcomposer.com" } } }
导入依赖完成后目录:
注意:如果是http访问需要修改CAS/client.php文件中的317行https修改为http
三、新建cas应用
在app目录下新建cas应用目录如:
IndexController 类中的代码
<?php namespace app\cas\controller; use cmf\controller\HomeBaseController; use phpCAS; class IndexController extends HomeBaseController { public function index() { phpCAS::setDebug(); // Enable verbose error messages. Disable in production! phpCAS::setVerbose(true); // Initialize phpCAS phpCAS::client(CAS_VERSION_2_0, "localhost", 8443, "cas"); // 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(); // 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(); } echo phpCAS::getVersion(); $this->assign("user", phpCAS::getUser()); $this->fetch(); } }
四:访问
在浏览器中访问:http://localhost/thinkcas/public/cas
thinkcas是你自己的项目名称
输入用户名/密码:casuser::Mellon
登录成功后:显示phpCAS的版本号1.3.7
猜你喜欢
- 2024-10-01 单点登录终极方案之 CAS 应用及原理
- 2024-10-01 Spring Boot+CAS 单点登录,如何对接数据库?
- 2024-10-01 cas单点登录服务器连接数据库 cas单点登出
- 2024-10-01 shiro集成spring使用cas单点登录配置
- 2024-10-01 聊聊单点登录(SSO)中的CAS认证,看完秒懂!
- 2024-10-01 单点登录(SSO)解决方案介绍 单点登录实现流程
- 2024-10-01 Java实现SSO单点登录 java单点登录解决方案
- 2024-10-01 Spring Security 项目模块及依赖项详解
- 2024-10-01 基于spring-security+jwt与cas-server5.3对接
- 2024-10-01 单点登录(SSO)看这一篇就够了 单点登录的三种实现方式简书
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- oraclesql优化 (66)
- 类的加载机制 (75)
- feignclient (62)
- 一致性hash算法 (71)
- dockfile (66)
- 锁机制 (57)
- javaresponse (60)
- 查看hive版本 (59)
- phpworkerman (57)
- spark算子 (58)
- vue双向绑定的原理 (68)
- springbootget请求 (58)
- docker网络三种模式 (67)
- spring控制反转 (71)
- data:image/jpeg (69)
- base64 (69)
- java分页 (64)
- kibanadocker (60)
- qabstracttablemodel (62)
- java生成pdf文件 (69)
- deletelater (62)
- com.aspose.words (58)
- android.mk (62)
- qopengl (73)
- epoch_millis (61)
本文暂时没有评论,来添加一个吧(●'◡'●)