visto9259/lmcuser-api-tools-auth

Laminas Api Tools 的 LmcUser 认证

v1.0.0 2021-02-15 18:43 UTC

This package is auto-updated.

Last update: 2024-09-16 03:03:12 UTC


README

这是一个使用 LmcUser 认证服务的 Laminas Api Tools 认证适配器。该适配器与 api-tools-mvc-auth 模块一起使用。它允许在 API 服务中使用 LmcUser 认证服务。当向使用 LmcUser 进行用户认证的应用程序添加 Laminas API Tools 服务时,这非常有用。

一个用例是当应用程序的前端代码使用 API 调用同一域名地址,而无需在 API 请求中提供用户凭据时。如果用户已通过网站进行认证,适配器将返回由 LmcUser 认证服务提供的 User 实体的 AuthenticatedIdentity,否则返回 GuestIdentity

要求

查看 composer.json 文件内容以获取依赖项。

安装

使用 Composer

$ composer require visto9259/lmcuser-api-tools-auth

配置

请参阅 Api Tools Laminas MVC Auth 模块参考,了解如何添加自定义适配器,因为 Api Tools Admin 用户界面不支持自定义适配器。

在您的配置文件中,无论是 local.phpglobal.php 还是另一个自动加载配置文件,请将条目添加到 api-tools-mvc-auth

'api-tools-mvc-auth' => [
   'authentication' => [
      'adapters' => [
         'myLmcUserAuth' => [
            'adapter' => '\LmcUserApiToolsAuth\Adapter\AuthAdapter',
            'options' => [
                'authentication_service' => 'lmcuser_auth_service',
            ],
        ],
      ],
   ], 
]

一旦将认证适配器添加到配置文件中,您就可以通过 Api Tools Admin 用户界面使用它来定义服务中要使用的认证类型。它将显示为(使用上述示例)myLmcUserAuth (oauth2)

您还可以在 api-tools-mvc-auth 配置键中手动配置它。

'api-tools-mvc-auth' => [
   'authentication' => [
      'map' => [
        'MyApiService' => 'myLmcUserAuth',
      ],
   ], 
]

问题

请在此处提交问题和疑问 here