{"id":13684128,"url":"https://github.com/UseMuffin/Tokenize","last_synced_at":"2025-04-30T20:33:04.717Z","repository":{"id":55641609,"uuid":"50255306","full_name":"UseMuffin/Tokenize","owner":"UseMuffin","description":"Security tokens for CakePHP","archived":false,"fork":false,"pushed_at":"2020-12-16T06:20:19.000Z","size":75,"stargazers_count":13,"open_issues_count":4,"forks_count":11,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-12T05:37:03.406Z","etag":null,"topics":[],"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/UseMuffin.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":"2016-01-23T19:47:51.000Z","updated_at":"2024-10-22T00:43:24.000Z","dependencies_parsed_at":"2022-08-15T05:20:17.827Z","dependency_job_id":null,"html_url":"https://github.com/UseMuffin/Tokenize","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FTokenize","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FTokenize/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FTokenize/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/UseMuffin%2FTokenize/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/UseMuffin","download_url":"https://codeload.github.com/UseMuffin/Tokenize/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251777706,"owners_count":21642212,"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-08-02T14:00:26.701Z","updated_at":"2025-04-30T20:33:04.708Z","avatar_url":"https://github.com/UseMuffin.png","language":"PHP","funding_links":[],"categories":["Authentication and Authorization"],"sub_categories":[],"readme":"# Tokenize\n\n[![Build Status](https://img.shields.io/travis/UseMuffin/Tokenize/master.svg?style=flat-square)](https://travis-ci.org/UseMuffin/Tokenize)\n[![Coverage Status](https://img.shields.io/codecov/c/github/UseMuffin/Tokenize.svg?style=flat-square)](https://codecov.io/github/UseMuffin/Tokenize)\n[![Total Downloads](https://img.shields.io/packagist/dt/muffin/tokenize.svg?style=flat-square)](https://packagist.org/packages/muffin/tokenize)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](LICENSE)\n\nSecurity tokens for CakePHP 3.\n\n## Why?\n\nEver wanted to force users to activate their account upon registration?\n\nOr maybe just a confirmation link when updating their credentials?\n\nOk, ok - maybe before cancelling a subscription or better, before sending funds out.\n\nWell, now you can. Attach listeners to your models for sending out emails (or any other\nnotification method of your choice), and you're good to go!\n\n## Install\n\nUsing [Composer][composer]:\n\n```\ncomposer require muffin/tokenize\n```\n\nYou then need to load the plugin. You can use the shell command:\n\n```\nbin/cake plugin load Muffin/Tokenize --routes\n```\n\nor by manually adding statement shown below to `bootstrap.php`:\n\n```php\nPlugin::load('Muffin/Tokenize', ['routes' =\u003e true]);\n```\n\nThis will ensure that the route for `/verify/:token` style URL is configured.\n\nYou can also customize the token's length, lifetime and table through `Configure` as\nshown below:\n\n```php\nConfigure::write('Muffin/Tokenize', [\n    'lifetime' =\u003e '3 days', // Default value\n    'length' =\u003e 32, // Default value\n    'table' =\u003e 'tokenize_tokens', // Default value\n]);\n```\n\nYou will also need to create the required table. A migration file was\nadded to help you with that:\n\n```sh\nbin/cake migrations migrate --plugin Muffin/Tokenize\n```\n\n## How it works\n\nWhen creating or updating a record, and if the data contains any *tokenized* field(s), a token\nwill automatically be created along with the value of the field(s) in question.\n\nWhen this happens the `Model.afterTokenize` event is fired and passed the operation's related\nentity and the associated token that was created for it.\n\nThe initial (save or update) operation resumes but without the *tokenized* fields.\n\nThe *tokenized* fields will only be updated upon submission of their associated token.\n\n## Usage\n\nTo tokenize the `password` column on updates, add this to your `UsersTable`:\n\n```php\n$this-\u003eaddBehavior('Muffin/Tokenize.Tokenize', [\n    'fields' =\u003e ['password'],\n]);\n```\n\nIf instead you wanted to have it create a token both on account creation and credentials update:\n\n```php\n$this-\u003eaddBehavior('Muffin/Tokenize.Tokenize', [\n    'fields' =\u003e ['password'],\n    'implementedEvents' =\u003e [\n        'Model.beforeSave' =\u003e 'beforeSave',\n        'Model.afterSave' =\u003e 'afterSave',\n    ],\n]);\n```\n\nFinally, if you just wish to create a token on the fly for other custom scenarios (i.e. password-less\nlogin), you can manually create a token:\n\n```php\n$this-\u003eUsers-\u003etokenize($user['id']);\n```\n\nThe above operation, will return a `Muffin\\Tokenize\\Model\\Entity\\Token` instance.\n\nTo verify a token from  a controller's action:\n\n```php\n$result = $this-\u003eUsers-\u003eTokens-\u003everify($token);\n```\n\n## Patches \u0026 Features\n\n* Fork\n* Mod, fix\n* Test - this is important, so it's not unintentionally broken\n* Commit - do not mess with license, todo, version, etc. (if you do change any, bump them into commits of\ntheir own that I can ignore when I pull)\n* Pull request - bonus point for topic branches\n\nTo ensure your PRs are considered for upstream, you MUST follow the [CakePHP coding standards][standards].\n\n## Bugs \u0026 Feedback\n\nhttp://github.com/usemuffin/tokenize/issues\n\n## License\n\nCopyright (c) 2015, [Use Muffin][muffin] and licensed under [The MIT License][mit].\n\n[cakephp]:http://cakephp.org\n[composer]:http://getcomposer.org\n[mit]:http://www.opensource.org/licenses/mit-license.php\n[muffin]:http://usemuffin.com\n[standards]:http://book.cakephp.org/3.0/en/contributing/cakephp-coding-conventions.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUseMuffin%2FTokenize","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FUseMuffin%2FTokenize","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FUseMuffin%2FTokenize/lists"}