在使用apereo/phpcas 时出现报错

zyyzcr

问题描述

为实现统一身份认证引入apereo/phpcas,
通过composer require apereo/phpcas 安装

程序代码

            $casHost = config('plugin.sso.cas.host');
            $casPort = config('plugin.sso.cas.port');
            $casContext = config('plugin.sso.cas.context');
            $casValidateCert = config('plugin.sso.cas.validate_cert', true);
            $casVersion = config('plugin.sso.cas.version', '3.0');

            $serviceUrl = "http://" . $request->host() . $request->path();

            // 初始化CAS客户端
            phpCAS::client($casVersion, $casHost, $casPort, $casContext, $serviceUrl,false);

            if ($casValidateCert) {
                phpCAS::setCasServerCACert(config('plugin.sso.cas.cert_path'));
            } else {
                phpCAS::setNoCasServerValidation();
            }

            phpCAS::forceAuthentication();

            $username = phpCAS::getUser();
            if (empty($username)) {
                throw new \Exception('无法获取CAS用户名');
            }

            $attributes = phpCAS::getAttributes();
            \Log::info('CAS用户属性', $attributes);

            $userData = [
                'username' => $username,
                'nickname' => $username,
                'avatar' => '',
                'email' => $attributes['email'] ?? '',
                'mobile' => $attributes['mobile'] ?? '',
                'login_at' => date('Y-m-d H:i:s'),
            ];

            $request->session()->put('admin', $userData);
            return redirect('/account/index');

报错信息

当执行到 phpCAS::client($casVersion, $casHost, $casPort, $casContext, $serviceUrl,false);时,Worker进程退出,报错如下:

Worker[814111] process terminated
45 0 0
0个回答

🔝