{"id":20077587,"url":"https://github.com/digitaledgeit/zf2-authentication-module","last_synced_at":"2025-07-14T08:32:46.136Z","repository":{"id":12093985,"uuid":"14682352","full_name":"digitaledgeit/zf2-authentication-module","owner":"digitaledgeit","description":"Digital Edge IT authentication module for Zend Framework v2","archived":false,"fork":false,"pushed_at":"2014-07-10T14:40:03.000Z","size":236,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-20T07:23:00.147Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitaledgeit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-11-25T10:13:05.000Z","updated_at":"2014-07-10T14:40:04.000Z","dependencies_parsed_at":"2022-09-01T17:02:51.844Z","dependency_job_id":null,"html_url":"https://github.com/digitaledgeit/zf2-authentication-module","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/digitaledgeit/zf2-authentication-module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fzf2-authentication-module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fzf2-authentication-module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fzf2-authentication-module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fzf2-authentication-module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitaledgeit","download_url":"https://codeload.github.com/digitaledgeit/zf2-authentication-module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitaledgeit%2Fzf2-authentication-module/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265262683,"owners_count":23736448,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-13T15:09:05.975Z","updated_at":"2025-07-14T08:32:46.105Z","avatar_url":"https://github.com/digitaledgeit.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# DeitAuthenticationModule #\n\nDeitAuthenticationModule is a pre-built authentication module for Zend Framework v2. It provides log-in and log-out functionality with a high degree of flexibility. To restrict access to routes, controller actions or other resources, also check out our DeitAuthorisationModule module.\n\nFor a full featured authentication module see [ZfcUser](https://github.com/ZF-Commons/ZfcUser).\n\n## Installation ##\n### With Composer ###\nAdd `\"digitaledgeit/zf2-authentication-module\": \"master-dev\"` to the `require` section of your composer.json file and then run `composer update`.\n\n### Without Composer ###\nDownload the repo archive, create a new directory named `%app%/module/DeitAuthenticationModule` and extract the contents of the archive.\n\n## Configuration ##\n\nConfigure `application.config.php` to load the module:\n\n\t'modules' =\u003e array(\n\t\t'DeitAuthenticationModule',\n\t\t'Application',\n\t),\n\nConfigure an authentication adapter that implements \\Zend\\Authentication\\Adapter\\AdapterInterface.\n\n\t'service_manager' =\u003e array(\n\t\t'factories' =\u003e array(\n\t\t\t'deit_authentication_adapter' =\u003e function($sm) {\n\n\t\t\t\t//create an adapter\n\t\t\t\t//for example: http://framework.zend.com/manual/2.0/en/modules/zend.authentication.adapter.dbtable.html\n\t\t\t\t//for example: https://github.com/doctrine/DoctrineModule/blob/master/docs/authentication.md\n\n\t\t\t},\n\t\t),\n\t),\n\n\n## Getting the authenticated identity ##\n\nThe module provides a controller plugin and a view helper for fetching the identity.\n\n\t$this-\u003eidentity();\n\nWhen adapters like `\\Zend\\Authentication\\Adapter\\DbTable` or `\\DoctrineModule\\Authentication\\Adapter\\ObjectRepository` retrieve a database entity and store it as the identity in the session, then you often run into problems with the identity data stored in the session being out-of-date after the identity has been updated in the database (e.g. if they've updated their name and you use the `identity` view helper to fetch the user's name in the layout then the updated name won't display until next time the user logs in).\n\nTo circumvent this issue you may specify a callback to fetch the entity on each page request so its always up-to-date.\n\n\t'deit_authentication' =\u003e array(\n\t\t'fetch_entity_from_identity_callback' =\u003e function($identity, \\Zend\\ServiceManager\\ServiceLocatorInterface $sm) {\n\n\t\t\t//fetch and return your entity\n\n\t\t\t//for example: fetch a user based on the user's Facebook ID returned by the adapter\n\t\t\treturn $em-\u003efindOneById($identity['facebook_id');\n\n\t\t}\n\t),\n\n## Using a custom view ##\n\nThe default view is very basic and just displays the heading \"Log in\" and uses the form view helper to render the form. Changing the view to your own is simple. Just override the template mapping like so:\n\n\t'view_manager' =\u003e array(\n\t\t'template_map' =\u003e array(\n\t\t\t'deit-authentication-module/log-in' =\u003e __DIR__.'/../view/your-view-path/log-in.phtml',\n\t\t),\n\t),\n\n\tThe view is passed two variables, a `$form` and a feedback `$message`. When an error occurs the `$message` may contain a message similar to \"invalid credentials, please try again\".\n\n## Using a custom form ##\n\nOverride the `deit_authentication_form` key in the service manager to provide your own form. Forms must implement `\\DeitAuthenticationModule\\Form\\AuthenticationInterface` or extend `\\DeitAuthenticationModule\\Form\\AbstractAuthentication`.\n\n\t'service_manager' =\u003e array(\n        'factories' =\u003e array(\n            'deit_authentication_form' =\u003e function($sm) {\n                return new \\Application\\Form\\MyAuthenticationForm();\n            },\n        },\n    },\n\nBy default the form is validated on POST but this behaviour can be overridden by implementing the `isSubmitted($request)` method.\n\n\tclass MyForm extends \\DeitAuthenticationModule\\Form\\AbstractAuthentication {\n\t\tpublic function isSubmitted(\\Zend\\Http\\Request $request) {\n\t\t\treturn $request-\u003eisGet() \u0026\u0026 $request-\u003egetQuery('identity') \u0026\u0026 $request-\u003egetQuery('credential');\n\t\t}\n\t}\n\nIf your form doesn't provide an identity or credential field you can specify a callback to map the user submitted data to your adapter.\n\n\t'deit_authentication' =\u003e array(\n        'map_auth_data_to_adapter_callback' =\u003e function(array $data, \\Zend\\Authentication\\Adapter\\AdapterInterface $adapter) {\n\n\t\t\t//in this example the adapter has a single parameter (not identity and credential like the ones provided by Zend).\n\t\t\t//this will be useful for alternate log-in schemes like Facebook OAuth\n            if (isset($data['code'])) {\n                $adapter-\u003esetCode($data['code']);\n            }\n\n        },\n\t),\n\n## Listening for events ##\n\nThe authentication controller triggers two events, `log-in` and `log-out`. The module provides its own `\\Zend\\EventManager\\EventManager` and can be retrieved from the service manager using the  `deit_authentication_events` key.\n\n\tclass Module {\n\n\t\tpublic function onBootstrap(MvcEvent $event) {\n\n\t\t\t$sm = $event-\u003egetApplication()-\u003egetServiceManager();\n\t\t\t$em = $sm-\u003eget('deit_authentication_events');\n\n\t\t\t$em-\u003eattach('log-in', function($event /** @var \\DeitAuthenticationModule\\Event\\Authenticate $event */) {\n\n\t\t\t\tif ($event-\u003egetResult()-\u003eisValid()) {\n\t\t\t\t\t//handle the event here\n\t\t\t\t}\n\n\t\t\t});\n\n            $em-\u003eattach('log-out', function($event) {\n\n\t\t\t\t/**\n\t\t\t\t * @var mixed $oldIdentity\n\t\t\t\t */\n\t\t\t\t$oldIdentity = $event-\u003egetParam('identity');\n\n                //handle the event here\n\n            });\n\n\t\t}\n\n\t}\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaledgeit%2Fzf2-authentication-module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitaledgeit%2Fzf2-authentication-module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitaledgeit%2Fzf2-authentication-module/lists"}