visto9259 / lmcuser-api-tools-auth
LmcUser Authentication for Laminas Api Tools
Requires
Requires (Dev)
- laminas/laminas-servicemanager: ^3.0
- phpunit/phpunit: ^9.5.0
This package is auto-updated.
Last update: 2024-10-16 03:07:02 UTC
README
This is a Laminas Api Tools authentication adapter that uses the LmcUser authentication service. This adapter is used with the api-tools-mvc-auth module. It allows to use the LmcUser authentication service for an API service. This is useful when adding a Laminas API Tools service to an application that uses LmcUser for user authentication.
A use case would be when an application's front-end code uses API calls to the same domain address without needing to supply user credentials with the API request.
If the user is authenticated to the website, the adapter will return a AuthenticatedIdentity
with the User Entity provided by the LmcUser Authentication Service, otherwise a GuestIdentity
is returned.
Requirements
See the content of composer.json
for dependencies.
Installation
Using Composer
$ composer require visto9259/lmcuser-api-tools-auth
Configuration
Please refer to the Api Tools Laminas MVC Auth module reference for details on how to add a custom adapter since the Api Tools Admin user interface does not support custom adapters.
In your config files, either local.php
, global.php
or another autoload config file, add the entry to api-tools-mvc-auth
:
'api-tools-mvc-auth' => [ 'authentication' => [ 'adapters' => [ 'myLmcUserAuth' => [ 'adapter' => '\LmcUserApiToolsAuth\Adapter\AuthAdapter', 'options' => [ 'authentication_service' => 'lmcuser_auth_service', ], ], ], ], ]
Once the authentication adapter is added to the config file, you can use it to define the authentication type to use in the your service via the Api Tools Admin user interface.
It will appear as (using the above example) myLmcUserAuth (oauth2)
.
You can also configure it manually in the api-tools-mvc-auth
config key:
'api-tools-mvc-auth' => [ 'authentication' => [ 'map' => [ 'MyApiService' => 'myLmcUserAuth', ], ], ]
Issues
Please submit questions and issues here.