openconextapps/simplesamlphp-module-vootgroups

此包已被放弃,不再维护。没有建议的替代包。

从VOOT提供者检索组成员信息并将其添加到SAML属性

安装: 25

依赖: 0

建议者: 0

安全: 0

星星: 1

关注者: 3

分支: 0

开放问题: 2

类型:simplesamlphp-module

0.2.0 2015-09-01 14:36 UTC

This package is auto-updated.

Last update: 2024-06-17 13:32:48 UTC


README

简介

这是一个 simpleSAMLphp 的模块,用于从使用 OAuth 2.0 和 VOOT 协议(支持版本 1 和 2)保护的 API 服务中获取组成员资格,并将其添加到来自身份提供者的属性列表。

ssp-voot-groups

为什么?

因为当你已经是 SAML 服务提供者时,将 OAuth 2.0 和 REST API 客户端实现为获取组成员资格会很麻烦,而它们也可以成为接收到的属性的一部分。

谁?

如果你是一个连接到支持 VOOT 以发布登录你服务的用户组成员资格信息的身份联合服务的服务提供者。如果你目前已经在使用 simpleSAMLphp 作为 SAML SP 软件,你只需安装此模块。如果你使用其他软件,你还可以安装 simpleSAMLphp SAML 代理并安装此模块。

安装

此模块可以以两种方式安装

  1. 通过解压缩一个位于 modules/ 目录下的 发布 tarball;或者
  2. 使用 simpleSAMLphp 模块安装程序

对于第一种选项,下载 ssp-voot-groups.x.y.z.tar.gz 并将其解压缩到 simpleSAMLphp 的 modules/ 目录下。对于第二种选项,你需要有 Composer。然后应该只需运行

composer.phar require openconextapps/simplesamlphp-module-vootgroups

配置

以下是 VOOT 1.0 的示例配置。您可以将此放置在 metadata/saml20-idp-remote.php 中,您要附加组检索的身份提供者。

'authproc' => array(
    40 => array (
        'class' => 'vootgroups:AttributeAddVootGroups',
        'vootScope' => 'http://openvoot.org/groups',
        'vootEndpoint' => 'https://voot.example.org/groups/@me',
        'userIdAttribute' => 'uid',
        'targetAttribute' => 'isMemberOf',
        'clientConfig' => array (
            'authorize_endpoint' => 'https://auth.example.org/authorize',
            'client_id' => 'my_client_id',
            'client_secret' => 'my_client_secret',
            'token_endpoint' => 'https://auth.example.org/token',
        ),
        'storage' => array (
            'type' => 'SessionStorage',
        ),
    ),
),

对于 VOOT 2.0,使用 /me/groups 作为 vootEndpoint

如果您想使用支持 SQL 数据库的 PDO 后端存储,您可以修改上面的存储配置如下

'storage' => array (
    'type' => 'SessionStorage',
),

如果您使用 SQLite

'storage' => array(
    'type' => 'PdoStorage',
    'dsn' => 'sqlite:/var/simplesamlphp/data/oauth.sqlite',
),

确保此 oauth.sqlite 文件可以被 web 服务器写入。这可能涉及到设置文件权限、处理 SELinux 以及可能还需要一些 web 服务器配置。如果您使用 MySQL,可以使用以下

'storage' => array(
    'type' => 'PdoStorage',
    'dsn' => 'mysql:host=localhost;dbname=oauth',
    'username' => 'foo',
    'password' => 'bar',
), 

请参阅 PDO 文档 了解如何使用您喜欢的数据库。存储令牌的数据库模式作为 OAuth 客户端的一部分,可以在 schema/db.sql 中找到。它已在 SQLite 和 MySQL 上进行过测试。导入此模式并配置数据库超出了本指南的范围。

在运行 Composer(见安装部分)后,模式可以在 vendor/fkooman/php-oauth-client/schema/db.sql 中找到。

注册

如上所示,OAuth 配置,但除此外,您还需要在 OAuth 2.0 服务中注册一个 redirect_uri。这取决于 simpleSAMLphp 的安装位置。例如

https://service.example.org/simplesaml/module.php/vootgroups/callback.php

这假设simpleSAMLphp已安装并且可以通过 http://service.example.org/simplesaml 访问,根据需要修改此URL。

如果您需要将 redirect_uri 作为授权请求的一部分提供,您还可以将 redirect_uri 参数添加到配置的 clientConfig 部分。

SURFconext

对于SURFconext,您可以使用以下配置

SURFconext API v 1 (VOOT 1.0)

40 => array (
    'class' => 'vootgroups:AttributeAddVootGroups',
    'vootEndpoint' => 'https://api.surfconext.nl/v1/social/rest/groups/@me',
    'vootScope' => 'read',
    'targetAttribute' => 'isMemberOf',
    'userIdAttribute' => 'urn:mace:dir:attribute-def:eduPersonPrincipalName',
    'clientConfig' => array (
        'authorize_endpoint' => 'https://api.surfconext.nl/v1/oauth2/authorize',
        'redirect_uri' => 'https://service.example.org/simplesaml/module.php/vootgroups/callback.php',
        'client_id' => 'MY_SURFCONEXT_CLIENT_ID',
        'client_secret' => 'MY_SURFCONEXT_CLIENT_SECRET',
        'credentials_in_request_body' => true,
        'token_endpoint' => 'https://api.surfconext.nl/v1/oauth2/token',
    ),
    'storage' => array (
        'type' => 'SessionStorage',
    ),
),

SURFconext API v 2 (VOOT 2.0)

40 => array (
    'class' => 'vootgroups:AttributeAddVootGroups',
    'vootEndpoint' => 'https://voot.surfconext.nl/me/groups',
    'vootScope' => 'groups',
    'targetAttribute' => 'isMemberOf',
    'userIdAttribute' => 'urn:mace:dir:attribute-def:eduPersonPrincipalName',
    'clientConfig' => array (
        'authorize_endpoint' => 'https://authz.surfconext.nl/oauth/authorize',
        'redirect_uri' => 'https://service.example.org/simplesaml/module.php/vootgroups/callback.php',
        'client_id' => 'MY_SURFCONEXT_CLIENT_ID',
        'client_secret' => 'MY_SURFCONEXT_CLIENT_SECRET',
        'token_endpoint' => 'https://authz.surfconext.nl/oauth/token',
    ),
    'storage' => array (
        'type' => 'SessionStorage',
    ),
),

注意:您需要为 userIdAttribute 使用一个属性。在示例中,我们使用 eduPersonPricipalName。另一个候选者是 eduPersonTargetedID。在将服务连接到SURFconext时,您可能需要请求使用此属性的权限。

如果您有一个包含冒号 (:) 的 client_id,请确保在 clientConfig 部分也设置 'credentials_in_request_body' => true

当然,您可以在生产设置中将 SessionStorage 替换为 PdoStorage(参见上文)。

许可证

此模块是免费软件,许可协议为Apache 2.0。有关详细信息,请参阅文件LICENSE。