{"id":13684352,"url":"https://github.com/jomweb/CakeImpersonate","last_synced_at":"2025-04-30T20:33:51.622Z","repository":{"id":57001210,"uuid":"108655069","full_name":"jomweb/CakeImpersonate","owner":"jomweb","description":"CakePHP Impersonate Plugin","archived":false,"fork":false,"pushed_at":"2020-01-08T00:56:15.000Z","size":78,"stargazers_count":7,"open_issues_count":1,"forks_count":3,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-22T12:11:56.049Z","etag":null,"topics":["authentication","cakephp-plugin","cakephp3","cakephp3x","impersonating-users"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jomweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-10-28T14:17:28.000Z","updated_at":"2022-08-25T14:30:41.000Z","dependencies_parsed_at":"2022-08-21T13:21:00.496Z","dependency_job_id":null,"html_url":"https://github.com/jomweb/CakeImpersonate","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomweb%2FCakeImpersonate","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomweb%2FCakeImpersonate/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomweb%2FCakeImpersonate/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jomweb%2FCakeImpersonate/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jomweb","download_url":"https://codeload.github.com/jomweb/CakeImpersonate/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251777763,"owners_count":21642220,"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":["authentication","cakephp-plugin","cakephp3","cakephp3x","impersonating-users"],"created_at":"2024-08-02T14:00:32.525Z","updated_at":"2025-04-30T20:33:51.392Z","avatar_url":"https://github.com/jomweb.png","language":"PHP","funding_links":[],"categories":["Miscellaneous"],"sub_categories":[],"readme":"# CakeImpersonate Plugin\n[![Build Status](https://travis-ci.org/jomweb/CakeImpersonate.svg?branch=master)](https://travis-ci.org/jomweb/CakeImpersonate)\n[![Coverage Status](https://codecov.io/gh/jomweb/CakeImpersonate/branch/master/graph/badge.svg)](https://codecov.io/gh/jomweb/CakeImpersonate)\n[![Latest Stable Version](https://poser.pugx.org/jomweb/cake-impersonate/v/stable.svg)](https://packagist.org/packages/jomweb/cake-impersonate)\n[![Minimum PHP Version](http://img.shields.io/badge/php-%3E%3D%205.6-8892BF.svg)](https://php.net/)\n[![License](https://poser.pugx.org/jomweb/cake-impersonate/license.svg)](https://packagist.org/packages/jomweb/cake-impersonate)\n[![Total Downloads](https://poser.pugx.org/jomweb/cake-impersonate/d/total.svg)](https://packagist.org/packages/jomweb/cake-impersonate)\n\n# Impersonate Component\nA component that stores the current authentication session and creates new session for impersonating Users. User can revert back to original authentication sessions without the need to re-login.\n\n## Warning\nAlways double check that an attacker cannot \"spoof\" other users in the controller actions. To prevent hijacking of users accounts that the current request User shouldn't/wouldn't have normal access to. You should enable [CsfrComponent](https://book.cakephp.org/3.0/en/controllers/components/csrf.html) and [SecurityComponent](https://book.cakephp.org/3.0/en/controllers/components/security.html) in your Controller when loading this component.\n\n***This Plugin does circumvent default authentication mechanisms***\n\n## Requirement\n1. CakePHP 3.7 and above.\n\n## Installation/Upgrading\n`\ncomposer require jomweb/cake-impersonate:\"^3.0\"\n`\n\n### Plugin Load\nOpen \\src\\Application.php add\n```php\n$this-\u003eaddPlugin('CakeImpersonate');\n```\nto your bootstrap() method or call `bin/cake plugin load CakeImpersonate`\n\n### Component Load\nLoad the component from controller\n```php\n$this-\u003eloadComponent('CakeImpersonate.Impersonate'); \n```\n\n### Configure Session Key\nOpen `configure\\app.php` and add\n```php\n'Impersonate' =\u003e [\n    'sessionKey' =\u003e 'OriginalAuth'\n]\n\n```\nto the `return [];` or use `Configure::write('Impersonate.sessionKey', 'OriginalAuth');` when loading the component.\n\n## Usage\n### Impersonate user\nThis requires the request to be a `POST`, `PUT`, `DELETE` so it can be protected by `SecurityComponent` and `CsrfComponent`\n```php\n$this-\u003eImpersonate-\u003elogin($userIdToImpersonate);\n```\n\n### Check current user is impersonated\n```php\n$this-\u003eImpersonate-\u003eisImpersonated();\n```\n\n### Logout from impersonating\n```php\n$this-\u003eImpersonate-\u003elogout();\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomweb%2FCakeImpersonate","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjomweb%2FCakeImpersonate","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjomweb%2FCakeImpersonate/lists"}