# Authentication example when use Psr handler

**URL:** https://discourse.laminas.dev/t/authentication-example-when-use-psr-handler/2773
**Category:** Components & MVC
**Tags:** laminas-authentication
**Created:** [February 15, 2022, 5:55pm UTC](https://discourse.laminas.dev/t/authentication-example-when-use-psr-handler/2773 "2022-02-15T17:55:54Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![voltan](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/voltan/32/710_2.png) [@voltan](https://discourse.laminas.dev/u/voltan)
#### Post date: [February 15, 2022, 5:55pm UTC](https://discourse.laminas.dev/t/authentication-example-when-use-psr-handler/2773/1 "2022-02-15T17:55:54Z")

</div>

Hello

I set up some Middleware before my controller ( and have to change the controller to PSR handler ), I start work on the login handler Instead login controller and I don’t have access to MVC plugins in the handler.

DO you have any examples of Authentication in handler and Authentication adaptor?

I want to make sure I am in true way in this part

Best

---

<div class="post-metadata">

### Author: ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)
#### Post date: [February 15, 2022, 7:07pm UTC](https://discourse.laminas.dev/t/authentication-example-when-use-psr-handler/2773/2 "2022-02-15T19:07:00Z")

</div>

> [@voltan](#):
>
> …I don’t have access to MVC plugins in the handler.

In a controller the [`identity` plugin](https://docs.laminas.dev/laminas-mvc-plugin-identity/) can be used. This plugin uses the [`AuthenticationService` of laminas-authentication](https://docs.laminas.dev/laminas-authentication/intro/#introduction):

> <https://github.com/laminas/laminas-mvc-plugin-identity/blob/d22e7fb74f0395828df5cd42ed55d23a98569ed1/src/Identity.php#L56-L60>

So inject the `AuthenticationService` directly into your handler and you can work with it.

---

<div class="post-metadata">

### Author: ![voltan](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/voltan/32/710_2.png) [@voltan](https://discourse.laminas.dev/u/voltan)
#### Post date: [February 15, 2022, 8:42pm UTC](https://discourse.laminas.dev/t/authentication-example-when-use-psr-handler/2773/3 "2022-02-15T20:42:24Z")

</div>

thank you very much, I try it tomorrow

---

<div class="post-metadata">

### Author: ![voltan](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/voltan/32/710_2.png) [@voltan](https://discourse.laminas.dev/u/voltan)
#### Post date: [February 23, 2022, 4:24am UTC](https://discourse.laminas.dev/t/authentication-example-when-use-psr-handler/2773/4 "2022-02-23T04:24:22Z")

</div>

Hello, it’s run in handler successfully. I will write detail and publish source code asap
