dbp/relay-core-connector-ldap-bundle

Relay API网关的模板包

v0.2.6 2024-09-11 08:33 UTC

README

GitHub | Packagist |

core_connector_ldap 包提供了实现 AuthorizationDataProviderInterface 的代码,用于从 LDAP 服务器检索用户授权数据。

包安装

您可以直接从 packagist.org 安装此包。

composer require dbp/relay-core-connector-ldap-bundle

集成到Relay API服务器

  • 将包添加到您的 config/bundles.php 文件中,在 DbpRelayCoreBundle 之前
...
Dbp\Relay\CoreConnectorLdapBundle\DbpRelayCoreConnectorLdapBundle::class => ['all' => true],
Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true],
];

如果您将 DBP API Server Template 作为您的 Symfony 应用的模板使用,则这应该已经为您生成了。

  • 运行 composer install 清除缓存

配置

该包具有 rolesattributesldap 配置值,您可以在您的应用程序中指定这些值,无论是通过硬编码还是通过引用环境变量。

为此,在应用程序中创建 config/packages/dbp_relay_core_connector_ldap.yaml,内容如下

dbp_relay_core_connector_ldap:
  roles:
    - name: ROLE_LIBRARY_MANAGER
    - name: ROLE_LIBRARY_USER
  attributes:
    - name: LIBRARY_IDS
  ldap:
    host: '%env(LDAP_AUTH_CONNECTOR_LDAP_HOST)%'
    base_dn: '%env(LDAP_AUTH_CONNECTOR_LDAP_BASE_DN)%'
    username: '%env(LDAP_AUTH_CONNECTOR_LDAP_USER)%'
    password: '%env(LDAP_AUTH_CONNECTOR_LDAP_PASS)%'
    encryption: '%env(LDAP_AUTH_CONNECTOR_LDAP_ENCRYPTION)%'
    attributes:
      identifier: '%env(LDAP_AUTH_CONNECTOR_LDAP_ATTRIBUTE_IDENTIFIER)%'

如果您将 DBP API Server Template 作为您的 Symfony 应用的模板使用,则配置文件应该已经为您生成了。

有关包配置的更多信息,请参阅 https://symfony.com.cn/doc/current/bundles/configuration.html

开发与测试

  • 安装依赖项: composer install
  • 运行测试: composer test
  • 运行linters: composer run lint
  • 运行 cs-fixer: composer run cs-fix

包依赖项

如果您在一个包中安装包,不要忘记从主应用程序中拉取依赖项。

# updates and installs dependencies of dbp/relay-core-connector-ldap-bundle
composer update dbp/relay-core-connector-ldap-bundle