tillikum/zf2-cas-authentication-adapter

此包已被废弃,不再维护。未建议替代包。

Zend Framework 2 的 CAS 认证适配器

v0.1.0 2013-08-03 19:22 UTC

This package is not auto-updated.

Last update: 2020-01-19 16:15:08 UTC


README

CAS 是耶鲁大学最初创建的一种认证系统,为应用程序提供了一种可信赖的用户认证方式。

http://www.jasig.org/cas/

要求

  • Zend Framework 2 HTTP 客户端
  • Zend Framework 2 认证框架

安装

将此仓库添加到您的 composer.json

{
    "require": {
        "tillikum/zf2-cas-authentication-adapter": "~0.0"
    }
}

然后执行 composer update

使用

<?php

use Tillikum\Authentication\Adapter\Cas as CasAdapter;
use Zend\Authentication;
use Zend\Http;

$httpClient = new Http\Client();

/** Standalone **/

$adapter = new CasAdapter(
    $httpClient,
    'https:///cas'
);

// You'll need to do this in response to requests to your system:
$adapter->setServiceValidateParameters(
    array(
        'service' => 'http://my/current/url',
        'ticket' => 'ST-ACME-123',
    )
);

$result = $adapter->authenticate();

/** Plugged in to Zend\Authentication **/

// Assuming we're still using the $adapter constructed above:

$authService = new Authentication\AuthenticationService(
    new Authentication\Storage\NonPersistent(),
    $adapter
);

$result = $authService->authenticate();

故障排除

与 CAS 服务器通信时的 SSL 问题

您可以将任何您喜欢或需要的选项传递给 Zend\Http\Client。以下示例可能需要为您的环境提供绝对 CA 路径:

<?php

$httpClient = new Zend\Http\Client();
$httpClient->setOptions(
    array(
        'sslcapath' => '/etc/ssl/certs'
    )
);

// ... Pass the modified HTTP client to the adapter as usual ...