bingher/php-cas-client

php cas client from phpCAS

v2.0.0 2023-12-08 02:13 UTC

This package is auto-updated.

Last update: 2024-11-08 04:35:59 UTC


README

php cas client,create from phpCAS

composer install

composer require bingher/php-cas-client

how to use at thinkphp

create config file config/cas.php

<?php
return [
    'debug'      => true,
    'host'       => 'cas.server.com',
    'context'    => '/cas',
    'port'       => 8443,
    'ca_cert_file' => \Env::get('config_path') . '/cas.pem',
    'log_file'   => \Env::get('runtime_path') . '/log/' . date('Ym') . '/' . date('d') . '_cas.log',
];

import at controller app\index\controller\Test.php

<?php
namespace app\index\controller;

use bingher\phpcas\Cas;
use think\facade\Config;

class Test
{
    /**
     * http://www.tp.com/index/test/login
     * 测试环境 测试账号test2 123456
     */
    public function login()
    {
        $cas  = new Cas(Config::get('cas.'));
        $user = $cas->login();
        //TODO you login logic
    }

    /**
     * 退出登录
     * @return [type] [description]
     */
    public function logout()
    {
        $callbackUrl = 'http://www.tp.com'; //如果设置为空默认回调到网站首页
        $cas = new Cas(Config::get('cas.'));
        $cas->logout($callbackUrl);
    }

}