raphox/alb-open-id-server-bundle

OpenID 提供者包

安装: 10

依赖者: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 2

类型:symfony-bundle

dev-master 2012-10-31 13:23 UTC

This package is not auto-updated.

Last update: 2024-09-28 13:37:09 UTC


README

OpenID 提供者包。

安装

步骤1: 下载 AlbOpenIDServerBundle

使用供应商脚本

在你的依赖文件中添加以下行

[AlbOpenIDServerBundle]
    git=git://github.com/arnaud-lb/AlbOpenIDServerBundle.git
    target=bundles/Alb/OpenIDServerBundle
    
[php-openid]
    git=git://github.com/openid/php-openid.git
    target=openid/php-openid

现在,运行供应商脚本以下载包

$ php bin/vendors install

使用子模块

如果你更喜欢使用 git 子模块,则运行以下命令

$ git submodule add git://github.com/arnaud-lb/AlbOpenIDServerBundle.git vendor/bundles/Alb/AlbOpenIDServerBundle
$ git submodule add git://github.com/openid/php-openid.git vendor/openid/php-openid
$ git submodule update --init

使用 composer

待办事项

步骤2: 配置自动加载器

如果你使用 composer 安装了包,则可以跳过此步骤。

Alb 命名空间添加到你的自动加载器中

<?php

// app/autoload.php

$loader->registerNamespaces(array(
    // ...
    'Alb' => __DIR__.'/../vendor/bundles',
));

步骤3: 配置包含路径

php-openid 依赖于其类在包含路径中

<?php

/// app/autoload.php

...

set_include_path(
    get_include_path()
    . PATH_SEPARATOR 
    . __DIR__ . '/../vendor/openid/php-openid'
);

...

步骤4: 启用包

最后,在 kernel 中启用包

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        // ...
        new Alb\OpenIDServerBundle\AlbOpenIDServerBundle(),
    );
}

创建适配器

此包依赖于适配器,该适配器适用于可能特定于您应用程序的事物。适配器必须实现 Alb\OpenIDServerBundle\Adapter\AdapterInterface

以下是一个简单的实现示例

<?php

namespace <your_namespace>;

use Alb\OpenIDServerBundle\Adapter\AdapterInterface;

class Adapter implements AdapterInterface
{
    public function getUserUnique($user)
    {
        return $user->getId();
    }
}

使用此类声明一个服务

# app/config/config.yml

services:
    my_open_id_server_adapter:
        class:  <your_namespace>\Adapter

配置

包配置

将以下内容添加到 app/config/config.yml

# app/config/config.yml

alb_open_id_server_bundle:
    service:
        adapter: my_open_id_server_adapter

路由

将以下内容添加到 app/config/routing.yml

# app/config/routing.yml
alb_open_id_server:
    resource: "@AlbOpenIDServerBundle/Resources/config/routing.xml"
    prefix: /openid

安全

为了访问会话安全数据,将以下内容添加到 app/config/security.yml

security:
    ...

    firewalls:
        ...

        secured_openid:
            pattern:    ^/openid
            anonymous: ~
            http_basic:
                realm: "Secured OpenID Area"

使用

OpenID 端点位于 /openid(取决于路由前缀)

待办事项

  • 添加测试
  • 更多文档