dbp/relay-core-connector-textfile-bundle

Relay API网关的模板包

v0.1.12 2024-06-25 12:46 UTC

This package is auto-updated.

Last update: 2024-09-23 04:32:21 UTC


README

GitHub | Packagist

core_connector_textfile 包提供了对 AuthorizationDataProviderInterface 的实现,该接口从包的配置文件中检索用于访问控制的用户属性。

包安装

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

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

集成到Relay API服务器

  • 将包添加到您的 config/bundles.php 中,位于 DbpRelayCoreBundle 前面
...
Dbp\Relay\CoreConnectorTextfileBundle\DbpRelayCoreConnectorTextfileBundle::class => ['all' => true],
Dbp\Relay\CoreBundle\DbpRelayCoreBundle::class => ['all' => true],
];

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

  • 运行 composer install 清除缓存

配置

您可以使用包配置定义用户授权属性。为此,创建 config/packages/dbp_relay_core_connector_textfile.yaml

以下是一个示例配置文件

dbp_relay_core_connector_textfile:
  # used to define groups used for the attribute mapping
  groups: 
    - name: DEVELOPERS
      users:
        - junior
        - senior

  # used to declare available attributes
  attributes: 
    - name: ROLE_DEVELOPER
      default_value: false # default value: 'null' for scalar and '[]' for array attributes
    - name: ORGANIZATION_UNITS 
      array: true # default value: 'false'

  # used to define values for the attributes
  # each mapping entry specifies a value for an attribute for one or many users and/or groups
  attribute_mapping: 
    - name: ROLE_DEVELOPER
      groups:
        - DEVELOPERS
      value: true
    - name ORGANIZATION_UNITS
      groups:
        - DEVELOPERS
      values:
        - 1
        - 2
    - name ORGANIZATION_UNITS
      users:
        - foo
      values:
        - 3

如果您使用的是 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-textfile-bundle
composer update dbp/relay-core-connector-textfile-bundle