# How to add authentication adapter to controller?

**URL:** <https://discourse.laminas.dev/t/how-to-add-authentication-adapter-to-controller/1179>\
**Category:** API Tools\
**Tags:** apigility\
**Created:** [September 6, 2019, 10:26am UTC](https://discourse.laminas.dev/t/how-to-add-authentication-adapter-to-controller/1179 "2019-09-06T10:26:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![testuser](https://avatars.discourse-cdn.com/v4/letter/t/e495f1/32.png) [@testuser](https://discourse.laminas.dev/u/testuser)\
**Post date:** [September 6, 2019, 10:26am UTC](https://discourse.laminas.dev/t/how-to-add-authentication-adapter-to-controller/1179/1 "2019-09-06T10:26:11Z")

</div>

This works:

```
return [
    'zf-mvc-auth' => [
        'authentication' => [
            'map' => [
                'Admin\\MyModule\\Controller' => 'session',
            ],

```

but it is applicable to all controllers. It means that cannot be controller without adapter.  
But this doesn’t:

```
return [
    'zf-mvc-auth' => [
        'authentication' => [
            'map' => [
                'Admin\\MyModule\\Controller\\UserController' => 'session',
            ],

```

because of this line [https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Authentication/DefaultAuthenticationListener.php#L233](https://github.com/zfcampus/zf-mvc-auth/blob/master/src/Authentication/DefaultAuthenticationListener.php#L233) where script added double backslashes to the $api variable which will not matches with $controller name.

‘Admin\MyModule\Controller\UserController\’ - this will be assign to the $api variable;  
‘Admin\MyModule\Controller\UserController’ - this will be assign to the $controller variable. How to get around of this?
